Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed TrackerMIL one frame late #7399

Merged
merged 5 commits into from
Jan 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fixed incorrect frame data sent to tracker
  • Loading branch information
klakhov committed Jan 26, 2024
commit ef317b5702f94e74978359b9523c15e2b8ed0a95
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ import withVisibilityHandling from './handle-popover-visibility';
interface Props {
labels: any[];
canvasInstance: Canvas;
canvasReady: boolean;
jobInstance: any;
isActivated: boolean;
states: any[];
@@ -85,6 +86,7 @@ interface State {
trackedShapes: TrackedShape[];
activeTracker: OpenCVTracker | null;
trackers: OpenCVTracker[];
lastTrackedFrame: number | null;
}

const core = getCore();
@@ -98,7 +100,7 @@ function mapStateToProps(state: CombinedState): Props {
zLayer: { cur: curZOrder },
},
job: { instance: jobInstance, labels },
canvas: { activeControl, instance: canvasInstance },
canvas: { activeControl, instance: canvasInstance, ready: canvasReady },
player: {
frame: { number: frame, data: frameData },
},
@@ -113,6 +115,7 @@ function mapStateToProps(state: CombinedState): Props {
isActivated: activeControl === ActiveControl.OPENCV_TOOLS,
activeControl,
canvasInstance: canvasInstance as Canvas,
canvasReady,
defaultApproxPolyAccuracy,
jobInstance,
curZOrder,
@@ -157,6 +160,7 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
trackedShapes: [],
trackers: openCVWrapper.isInitialized ? Object.values(openCVWrapper.tracking) : [],
activeTracker: openCVWrapper.isInitialized ? Object.values(openCVWrapper.tracking)[0] : null,
lastTrackedFrame: null,
};
}

@@ -168,7 +172,7 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
public componentDidUpdate(prevProps: Props, prevState: State): void {
const { approxPolyAccuracy } = this.state;
const {
isActivated, defaultApproxPolyAccuracy, canvasInstance, toolsBlockerState,
isActivated, defaultApproxPolyAccuracy, canvasInstance, canvasReady, toolsBlockerState,
} = this.props;

if (!prevProps.isActivated && isActivated) {
@@ -202,7 +206,8 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
!!this.activeTool?.switchBlockMode) {
this.activeTool.switchBlockMode(toolsBlockerState.algorithmsLocked);
}
this.checkTrackedStates(prevProps);

if (canvasReady) this.checkTrackedStates();
}

public componentWillUnmount(): void {
@@ -419,15 +424,19 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
});
};

private checkTrackedStates(prevProps: Props): void {
private checkTrackedStates(): void {
const {
frame,
states: objectStates,
fetchAnnotations,
switchNavigationBlocked,
} = this.props;
const { trackedShapes } = this.state;
if (prevProps.frame !== frame && trackedShapes.length) {
const { trackedShapes, lastTrackedFrame } = this.state;
if (lastTrackedFrame !== frame && trackedShapes.length) {
this.setState({
lastTrackedFrame: frame,
});

type AccumulatorType = {
[index: string]: TrackedShape[];
};