Skip to content

Commit

Permalink
Fixed hash for shapes, tags and skeletons (cvat-ai#6517)
Browse files Browse the repository at this point in the history
<!-- Raise an issue to propose your change
(https://github.com/opencv/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the [Contribution
guide](https://opencv.github.io/cvat/docs/contributing/). -->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
<!-- Why is this change required? What problem does it solve? If it
fixes an open
issue, please link to the issue here. Describe your changes in detail,
add
screenshots. -->

### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable for some reason, then ~~explicitly
strikethrough~~ the whole
line. If you don't do that, GitHub will show incorrect progress for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [x] I submit my changes into the `develop` branch
- [x] I have added a description of my changes into the
[CHANGELOG](https://github.com/opencv/cvat/blob/develop/CHANGELOG.md)
file
- [ ] I have updated the documentation accordingly
- [ ] I have added tests to cover my changes
- [ ] I have linked related issues (see [GitHub docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
- [x] I have increased versions of npm packages if it is necessary

([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning),

[cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning)
and

[cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning))

### License

- [x] I submit _my code changes_ under the same [MIT License](
https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.
  • Loading branch information
bsekachev authored Jul 20, 2023
1 parent e379444 commit 123a86c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- \[SDK\] Ability to create attributes with blank default values
(<https://github.com/opencv/cvat/pull/6454>)
- \[SDK\] SDK should not change input data in models (<https://github.com/opencv/cvat/pull/6455>)
- Export hash for shapes and tags in a corner case (<https://github.com/opencv/cvat/pull/6517>)
- 3D job can not be opened in validation mode (<https://github.com/opencv/cvat/pull/6507>)
- Fixed SAM plugin (403 code for workers in organizations) (<https://github.com/opencv/cvat/pull/6514>)
- Using initial frame from query parameter to open specific frame in a job
Expand Down
4 changes: 3 additions & 1 deletion cvat-core/src/annotations-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ export default class Collection {
frame: state.frame,
label_id: state.label.id,
group: 0,
source: state.source,
});
} else {
checkObjectType('state occluded', state.occluded, 'boolean', null);
Expand All @@ -839,6 +840,7 @@ export default class Collection {
frame: state.frame,
group: 0,
label_id: state.label.id,
outside: state.outside || false,
occluded: state.occluded || false,
points: state.shapeType === 'mask' ? (() => {
const { width, height } = this.frameMeta[state.frame];
Expand Down Expand Up @@ -903,7 +905,7 @@ export default class Collection {
frame: state.frame,
type: element.shapeType,
points: [...element.points],
zOrder: state.zOrder,
z_order: state.zOrder,
outside: element.outside || false,
occluded: element.occluded || false,
rotation: element.rotation || 0,
Expand Down
20 changes: 19 additions & 1 deletion cvat-core/src/annotations-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1956,6 +1956,7 @@ export class SkeletonShape extends Shape {
group: this.group,
z_order: this.zOrder,
rotation: 0,
elements: undefined,
}));

const result: RawShapeData = {
Expand Down Expand Up @@ -2891,7 +2892,24 @@ export class SkeletonTrack extends Track {
// Method is used to export data to the server
public toJSON(): RawTrackData {
const result: RawTrackData = Track.prototype.toJSON.call(this);
result.elements = this.elements.map((el) => el.toJSON());
result.elements = this.elements.map((el) => ({
...el.toJSON(),
elements: undefined,
source: this.source,
group: this.group,
}));
result.elements.forEach((element) => {
element.shapes.forEach((shape) => {
shape.rotation = 0;
const { frame } = shape;
const skeletonShape = result.shapes
.find((_skeletonShape) => _skeletonShape.frame === frame);
if (skeletonShape) {
shape.z_order = skeletonShape.z_order;
}
});
});

return result;
}

Expand Down

0 comments on commit 123a86c

Please sign in to comment.