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

Display of Annotation Type #1192

Merged
merged 27 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fd3e896
resolved merge conflicts
Priya4607 Mar 23, 2020
1ec2869
annotation_type field support for tags, tf_annotation api, cvat-dumpe…
Priya4607 Mar 23, 2020
98f1fd2
unit test fix
Priya4607 Mar 23, 2020
5c170c8
squashed migrations
Priya4607 Mar 23, 2020
732f95c
updated CHANGELOG.md
Priya4607 Apr 13, 2020
b79deae
fixed unit test issues
Priya4607 Apr 13, 2020
cec9060
Resolved merge conflicts
Priya4607 Apr 17, 2020
e21c824
minor fix
Priya4607 Apr 17, 2020
9bb111b
resolved merge conflicts
Priya4607 May 11, 2020
0405dbb
eslint fix
Priya4607 May 11, 2020
9d6a095
updated CHANGELOG.md [1.0.0-beta.2], changed cvat-canvas file
Priya4607 May 29, 2020
00598ab
Unit test case
Priya4607 May 29, 2020
48eca64
Merge branch 'develop' of https://github.com/opencv/cvat into auto_vs…
Priya4607 Jun 2, 2020
4bf3e48
updated CHANGELOG.md [1.1.0-alpha]
Priya4607 Jun 2, 2020
ec69c8a
resolved conflicts
Priya4607 Jun 2, 2020
904a206
fixed unit test
Priya4607 Jun 20, 2020
14659bd
resolved conflicts
Priya4607 Jun 20, 2020
30cda12
*removed empty migration files
Priya4607 Jun 30, 2020
c1149bf
resolved conflicts
Priya4607 Jun 30, 2020
3695a5d
unit test fix
Priya4607 Jun 30, 2020
adf086d
resolved conflicts
Priya4607 Jul 16, 2020
f34ba1f
Merge branch 'develop' of https://github.com/opencv/cvat into auto_vs…
Priya4607 Jul 18, 2020
cccecb0
minor changes
Priya4607 Jul 18, 2020
58e41fa
Merge branch 'develop' of https://github.com/opencv/cvat into auto_vs…
Priya4607 Jul 19, 2020
3513fe7
included migrations
Priya4607 Jul 19, 2020
c3590a1
updated CHANGELOG.md
Priya4607 Jul 20, 2020
562ea5f
updated CHANGELOG.md
Priya4607 Jul 23, 2020
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Ability to change orientation for poylgons/polylines in context menu (<https://github.com/opencv/cvat/pull/1571>)
- Ability to set the first point for polygons in points context menu (<https://github.com/opencv/cvat/pull/1571>)
- Added new tag annotation workspace (<https://github.com/opencv/cvat/pull/1570>)
- Annotation type support for tags, shapes and tracks (<https://github.com/opencv/cvat/pull/1192>)
- Annotation type support for CVAT Dumper/Loader (<https://github.com/opencv/cvat/pull/1192>)

### Changed
- Removed information about e-mail from the basic user information (<https://github.com/opencv/cvat/pull/1627>)
Expand Down Expand Up @@ -430,6 +432,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial version

## [0.6.1] - 2020-04-14
azhavoro marked this conversation as resolved.
Show resolved Hide resolved
### Added
- Annotation type to determine whether a drawn shape is auto annotated using Tensorflow Object detection API or manually annotated by the user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Priya4607 , some problems with merge. These lines are wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed those lines.

- Annotation_type field support for cvat dumper/loader
- Annotation_type field support for tags

## Template
```
## [Unreleased]
Expand Down
8 changes: 4 additions & 4 deletions cvat-canvas/src/typescript/canvasView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
}

private onEditDone(state: any, points: number[]): void {
if (state && points) {
if (state && points) {
const event: CustomEvent = new CustomEvent('canvas.edited', {
bubbles: false,
cancelable: true,
Expand Down Expand Up @@ -1733,14 +1733,14 @@ export class CanvasViewImpl implements CanvasView, Listener {

private addText(state: any): SVG.Text {
const { undefinedAttrValue } = this.configuration;
const { label, clientID, attributes } = state;
const { label, clientID, attributes, annotationType } = state;
const attrNames = label.attributes.reduce((acc: any, val: any): void => {
acc[val.id] = val.name;
return acc;
}, {});

return this.adoptedText.text((block): void => {
block.tspan(`${label.name} ${clientID}`).style('text-transform', 'uppercase');
block.tspan(`${label.name} ${clientID} (${annotationType})`).style('text-transform', 'uppercase');
for (const attrID of Object.keys(attributes)) {
const value = attributes[attrID] === undefinedAttrValue
? '' : attributes[attrID];
Expand Down Expand Up @@ -1878,7 +1878,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
'pointer-events': 'none',
'shape-rendering': 'geometricprecision',
'stroke-width': 0,
fill: state.color, // to right fill property when call SVG.Shape::clone()
fill: state.color, // to right fill property when call SVG.Shape::clone(
}).style({
opacity: 0,
});
Expand Down
3 changes: 3 additions & 0 deletions cvat-core/src/annotations-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@
frame: Math.min.apply(null, Object.keys(keyframes).map((frame) => +frame)),
shapes: Object.values(keyframes),
group: 0,
annotation_type: objectStates[0].annotationType,
label_id: label.id,
attributes: Object.keys(objectStates[0].attributes)
.reduce((accumulator, attrID) => {
Expand Down Expand Up @@ -763,13 +764,15 @@
points: [...state.points],
type: state.shapeType,
z_order: state.zOrder,
annotation_type: state.annotationType,
});
} else if (state.objectType === 'track') {
constructed.tracks.push({
attributes: attributes
.filter((attr) => !labelAttributes[attr.spec_id].mutable),
frame: state.frame,
group: 0,
annotation_type: state.annotationType,
label_id: state.label.id,
shapes: [{
attributes: attributes
Expand Down
42 changes: 41 additions & 1 deletion cvat-core/src/annotations-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
this.removed = false;
this.lock = false;
this.color = color;
this.annotationType = data.annotation_type;
this.updated = Date.now();
this.attributes = data.attributes.reduce((attributeAccumulator, attr) => {
attributeAccumulator[attr.spec_id] = attr.value;
Expand Down Expand Up @@ -295,6 +296,21 @@
}, [this.clientID], frame);
}

_saveAnnotationType(annotationType, frame) {
const undoAnnotationType = this.annotationType;
const redoAnnotationType = annotationType;

this.history.do(HistoryActions.CHANGED_ANNOTATION_TYPE, () => {
this.annotationType = undoAnnotationType;
this.updated = Date.now();
}, () => {
this.annotationType = redoAnnotationType;
this.updated = Date.now();
}, [this.clientID], frame);

this.annotationType = annotationType;
}

_validateStateBeforeSave(frame, data, updated) {
let fittedPoints = [];

Expand Down Expand Up @@ -381,6 +397,10 @@
}
}

if (updated.annotationType) {
checkObjectType('annotationType', data.annotationType, 'string', null);
}

return fittedPoints;
}

Expand All @@ -396,7 +416,8 @@
updateTimestamp(updated) {
const anyChanges = updated.label || updated.attributes || updated.points
|| updated.outside || updated.occluded || updated.keyframe
|| updated.zOrder || updated.hidden || updated.lock || updated.pinned;
|| updated.zOrder || updated.hidden || updated.lock || updated.pinned
|| updated.annotationType;

if (anyChanges) {
this.updated = Date.now();
Expand Down Expand Up @@ -492,6 +513,7 @@
frame: this.frame,
label_id: this.label.id,
group: this.group,
annotation_type: this.annotationType,
};
}

Expand Down Expand Up @@ -520,6 +542,7 @@
updated: this.updated,
pinned: this.pinned,
frame,
annotationType: this.annotationType,
};
}

Expand Down Expand Up @@ -619,6 +642,10 @@
this._saveHidden(data.hidden, frame);
}

if (updated.annotationType) {
this._saveAnnotationType(data.annotationType, frame);
}

this.updateTimestamp(updated);
updated.reset();

Expand Down Expand Up @@ -659,6 +686,7 @@
frame: this.frame,
label_id: this.label.id,
group: this.group,
annotation_type: this.annotationType,
attributes: Object.keys(this.attributes).reduce((attributeAccumulator, attrId) => {
if (!labelAttributes[attrId].mutable) {
attributeAccumulator.push({
Expand Down Expand Up @@ -726,6 +754,7 @@
last,
},
frame,
annotationType: this.annotationType,
};
}

Expand Down Expand Up @@ -1034,6 +1063,7 @@
outside: current.outside,
occluded: current.occluded,
attributes: {},
annotationType: current.annotationType,
} : undefined;

if (redoShape) {
Expand Down Expand Up @@ -1098,6 +1128,10 @@
this._saveAttributes(data.attributes, frame);
}

if (updated.annotationType) {
this._saveAnnotationType(data.annotationType, frame);
}

if (updated.keyframe) {
this._saveKeyframe(frame, data.keyframe);
}
Expand Down Expand Up @@ -1164,6 +1198,7 @@
frame: this.frame,
label_id: this.label.id,
group: this.group,
annotation_type: this.annotationType,
attributes: Object.keys(this.attributes).reduce((attributeAccumulator, attrId) => {
attributeAccumulator.push({
spec_id: attrId,
Expand Down Expand Up @@ -1194,6 +1229,7 @@
color: this.color,
updated: this.updated,
frame,
annotationType: this.annotationType,
};
}

Expand Down Expand Up @@ -1228,6 +1264,10 @@
this._saveColor(data.color, frame);
}

if (updated.annotationType) {
this._saveAnnotationType(data.annotationType, frame);
}

this.updateTimestamp(updated);
updated.reset();

Expand Down
2 changes: 1 addition & 1 deletion cvat-core/src/annotations-saver.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@

const keys = ['id', 'label_id', 'group', 'frame',
'occluded', 'z_order', 'points', 'type', 'shapes',
'attributes', 'value', 'spec_id', 'outside'];
'attributes', 'value', 'spec_id', 'annotation_type', 'outside'];

// Find created and updated objects
for (const type of Object.keys(exported)) {
Expand Down
2 changes: 2 additions & 0 deletions cvat-core/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function build() {
LogType,
HistoryActions,
colors,
AnnotationType,
} = require('./enums');

const {
Expand Down Expand Up @@ -531,6 +532,7 @@ function build() {
LogType,
HistoryActions,
colors,
AnnotationType,
},
/**
* Namespace is used for access to exceptions
Expand Down
17 changes: 17 additions & 0 deletions cvat-core/src/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@
CUBOID: 'cuboid',
});

/**
* Annotation type
* @enum {string}
* @name AnnotationType
* @memberof module:API.cvat.enums
* @property {string} MANUAL 'Manual'
* @property {string} AUTO 'Auto'
* @readonly
*/
const AnnotationType = Object.freeze({
MANUAL:'Manual',
AUTO:'Auto',
});

/**
* Logger event types
* @enum {string}
Expand Down Expand Up @@ -190,6 +204,7 @@
* @property {string} CHANGED_LOCK Changed lock
* @property {string} CHANGED_COLOR Changed color
* @property {string} CHANGED_HIDDEN Changed hidden
* @property {string} CHANGED_ANNOTATION_TYPE Changed annotation type
* @property {string} MERGED_OBJECTS Merged objects
* @property {string} SPLITTED_TRACK Splitted track
* @property {string} GROUPED_OBJECTS Grouped objects
Expand All @@ -209,6 +224,7 @@
CHANGED_PINNED: 'Changed pinned',
CHANGED_COLOR: 'Changed color',
CHANGED_HIDDEN: 'Changed hidden',
CHANGED_ANNOTATION_TYPE: 'Changed annotation type',
MERGED_OBJECTS: 'Merged objects',
SPLITTED_TRACK: 'Splitted track',
GROUPED_OBJECTS: 'Grouped objects',
Expand Down Expand Up @@ -241,5 +257,6 @@
LogType,
HistoryActions,
colors,
AnnotationType,
};
})();
19 changes: 18 additions & 1 deletion cvat-core/src/object-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* </br> Necessary fields: objectType, shapeType, frame, updated, group
* </br> Optional fields: keyframes, clientID, serverID
* </br> Optional fields which can be set later: points, zOrder, outside,
* occluded, hidden, attributes, lock, label, color, keyframe
* occluded, hidden, attributes, lock, label, color, keyframe, annotationType
*/
constructor(serialized) {
const data = {
Expand All @@ -39,6 +39,7 @@
color: null,
hidden: null,
pinned: null,
annotationType: null,
keyframes: serialized.keyframes,
group: serialized.group,
updated: serialized.updated,
Expand Down Expand Up @@ -68,6 +69,7 @@
this.lock = false;
this.color = false;
this.hidden = false;
this.annotationType = false;

return reset;
},
Expand Down Expand Up @@ -109,6 +111,20 @@
*/
get: () => data.shapeType,
},
annotationType: {
/**
* @name annotationType
* @type {module:API.cvat.enums.AnnotationType}
* @memberof module:API.cvat.classes.ObjectState
* @readonly
* @instance
*/
get: () => data.annotationType,
set: (annotationType) => {
data.updateFlags.annotationType = true;
data.annotationType = annotationType;
},
},
clientID: {
/**
* @name clientID
Expand Down Expand Up @@ -343,6 +359,7 @@

this.label = serialized.label;
this.lock = serialized.lock;
this.annotationType = serialized.annotationType;

if (typeof (serialized.zOrder) === 'number') {
this.zOrder = serialized.zOrder;
Expand Down
1 change: 1 addition & 0 deletions cvat-ui/src/actions/annotation-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ export function propagateObjectAsync(
label: objectState.label,
zOrder: objectState.zOrder,
frame: from,
annotationType: objectState.annotationType,
};

await sessionInstance.logger.log(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ export default class CanvasWrapperComponent extends React.PureComponent<Props> {
.filter((label: any) => label.id === activeLabelID)[0];
state.occluded = state.occluded || false;
state.frame = frame;
state.annotationType = 'Manual';
const objectState = new cvat.classes.ObjectState(state);
onCreateAnnotations(jobInstance, frame, [objectState]);
};
Expand Down Expand Up @@ -504,6 +505,7 @@ export default class CanvasWrapperComponent extends React.PureComponent<Props> {
points,
} = event.detail;
state.points = points;
state.annotationType = 'Manual';
onUpdateAnnotations([state]);
};

Expand Down
Loading