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

Bug fixes and tracking feature improvement #10

Merged
merged 3 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions cvat-canvas/src/typescript/canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ interface Canvas {

mode(): Mode;
cancel(): void;
// EDITED FOR USER STORY 12/13
trackObject(enable: boolean, objectID: number | null): void;
// EDITED END
configure(configuration: Configuration): void;
}

Expand All @@ -74,6 +77,12 @@ class CanvasImpl implements Canvas {
return this.view.html();
}

// EDITED FOR USER STORY 12/13
public trackObject(enable: boolean, objectID: number | null): void {
this.model.trackObject(enable, objectID);
}
// EDITED END

public setZLayer(zLayer: number | null): void {
this.model.setZLayer(zLayer);
}
Expand Down
12 changes: 12 additions & 0 deletions cvat-canvas/src/typescript/canvasController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export interface CanvasController {
drag(x: number, y: number): void;
disableDrag(): void;
fit(): void;

trackingElement: any; // EDITED FOR USER STORY 12/13
}

export class CanvasControllerImpl implements CanvasController {
Expand Down Expand Up @@ -147,4 +149,14 @@ export class CanvasControllerImpl implements CanvasController {
public get mode(): Mode {
return this.model.mode;
}

// EDITED FOR USER STORY 12/13
public set trackingElement(value: any) {
this.model.trackingElement = value;
}

public get trackingElement(): any {
return this.model.trackingElement;
}
// EDITED END
}
82 changes: 82 additions & 0 deletions cvat-canvas/src/typescript/canvasModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export enum UpdateReasons {
DRAG_CANVAS = 'drag_canvas',
ZOOM_CANVAS = 'zoom_canvas',
CONFIG_UPDATED = 'config_updated',
SWITCH_TRACKING = 'SWITCH_TRACKING', // EDITED START FOR USER STORY 12/13
}

export enum Mode {
Expand Down Expand Up @@ -163,6 +164,12 @@ export interface CanvasModel {

configure(configuration: Configuration): void;
cancel(): void;


// EDITED FOR USER STORY 12/13
trackObject(enable: boolean, trackedStateID: number | null): void;
trackingElement: any;
// EDITED END
}

export class CanvasModelImpl extends MasterImpl implements CanvasModel {
Expand All @@ -189,6 +196,24 @@ export class CanvasModelImpl extends MasterImpl implements CanvasModel {
splitData: SplitData;
selected: any;
mode: Mode;
// EDITED START FOR USER STORY 12/13
trackingElement: {
enable: boolean;
trackID: number | null;
mousecoords: any[];
scalemode: number;
trackrect: any | null;
trackedStates: any[];
trackedframes: any[];
trackedcentroids: any[];
trackedwidthheight: any[];
interpolatekeyframes: any[];
frameindex: {
frame: number | null;
index: number | null;
}
}
// EDITED END
};

public constructor() {
Expand Down Expand Up @@ -244,9 +269,56 @@ export class CanvasModelImpl extends MasterImpl implements CanvasModel {
},
selected: null,
mode: Mode.IDLE,

// EDITED START FOR USER STORY 12/13
trackingElement: {
enable: false,
trackID: null,
trackrect: null,
mousecoords: [],
scalemode: 0,
trackedStates: [],
trackedframes: [],
trackedcentroids: [],
trackedwidthheight: [],
interpolatekeyframes: [],
frameindex: {
frame: null,
index: null,
}
}
// EDITED END
};
}

// EDITED FOR USER STORY 12/13
public trackObject(enable: boolean, trackedStateID: number | null): void {
if (enable) {
this.trackingElement.enable = true;
this.data.trackingElement.trackID = trackedStateID;
} else {
this.data.trackingElement = {
enable: false,
trackID: null,
mousecoords: this.data.trackingElement.mousecoords,
scalemode: 0,
trackrect: this.data.trackingElement.trackrect,
trackedStates: [],
trackedframes: [],
trackedcentroids: [],
trackedwidthheight: [],
interpolatekeyframes: [],
frameindex: {
frame: null,
index: null,
}
}
}

this.notify(UpdateReasons.SWITCH_TRACKING);
}
// EDITED END

public setZLayer(zLayer: number | null): void {
this.data.zLayer = zLayer;
this.notify(UpdateReasons.SET_Z_LAYER);
Expand Down Expand Up @@ -631,4 +703,14 @@ export class CanvasModelImpl extends MasterImpl implements CanvasModel {
public get mode(): Mode {
return this.data.mode;
}

// EDITED FOR USER STORY 12/13
public set trackingElement(value: any) {
this.data.trackingElement = value;
}

public get trackingElement(): any {
return this.data.trackingElement;
}
// EDITED END
}
Loading