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

session.annotations.put() returns indexes of added objects #1493

Merged
merged 2 commits into from
May 5, 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-

### Changed
-
- cvat-core: session.annotations.put() now returns identificators of added objects (<https://github.com/opencv/cvat/pull/1493>)

### Deprecated
-
Expand Down
2 changes: 2 additions & 0 deletions cvat-core/src/annotations-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,8 @@
object.removed = false;
});
}, importedArray.map((object) => object.clientID), objectStates[0].frame);

return importedArray.map((value) => value.clientID);
}

select(objectStates, x, y) {
Expand Down
1 change: 1 addition & 0 deletions cvat-core/src/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@
* @method put
* @memberof Session.annotations
* @param {module:API.cvat.classes.ObjectState[]} data
* @returns {number[]} identificators of added objects
* array of objects on the specific frame
* @throws {module:API.cvat.exceptions.PluginError}
* @throws {module:API.cvat.exceptions.DataError}
Expand Down
16 changes: 12 additions & 4 deletions cvat-core/tests/api/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ describe('Feature: put annotations', () => {
zOrder: 0,
});

await task.annotations.put([state]);
const indexes = await task.annotations.put([state]);
annotations = await task.annotations.get(1);
expect(indexes).toBeInstanceOf(Array);
expect(indexes).toHaveLength(1);
expect(annotations).toHaveLength(length + 1);
});

Expand All @@ -108,7 +110,9 @@ describe('Feature: put annotations', () => {
zOrder: 0,
});

await job.annotations.put([state]);
const indexes = await job.annotations.put([state]);
expect(indexes).toBeInstanceOf(Array);
expect(indexes).toHaveLength(1);
annotations = await job.annotations.get(5);
expect(annotations).toHaveLength(length + 1);
});
Expand All @@ -128,7 +132,9 @@ describe('Feature: put annotations', () => {
zOrder: 0,
});

await task.annotations.put([state]);
const indexes = await task.annotations.put([state]);
expect(indexes).toBeInstanceOf(Array);
expect(indexes).toHaveLength(1);
annotations = await task.annotations.get(1);
expect(annotations).toHaveLength(length + 1);
});
Expand All @@ -148,7 +154,9 @@ describe('Feature: put annotations', () => {
zOrder: 0,
});

await job.annotations.put([state]);
const indexes = await job.annotations.put([state]);
expect(indexes).toBeInstanceOf(Array);
expect(indexes).toHaveLength(1);
annotations = await job.annotations.get(5);
expect(annotations).toHaveLength(length + 1);
});
Expand Down