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 fail for masks & skeletons with centered text #6753

Merged
merged 4 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Exporting project when its tasks has not data (<https://github.com/opencv/cvat/pull/6658>)
- Removing job assignee (<https://github.com/opencv/cvat/pull/6712>)
- UI fail when select a mask or a skeleton with center-aligned text (<https://github.com/opencv/cvat/pull/6753>)
- Fixed switching from organization to sandbox while getting a resource (<https://github.com/opencv/cvat/pull/6689>)
- You do not have permissions when user is cancelling automatic annotation (<https://github.com/opencv/cvat/pull/6734>)
- Automatic annotation progress bar is invisible if the app initialized on the task page
Expand Down
2 changes: 1 addition & 1 deletion cvat-canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-canvas",
"version": "2.17.3",
"version": "2.17.4",
"description": "Part of Computer Vision Annotation Tool which presents its canvas library",
"main": "src/canvas.ts",
"scripts": {
Expand Down
15 changes: 11 additions & 4 deletions cvat-canvas/src/typescript/canvasView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2558,7 +2558,12 @@ export class CanvasViewImpl implements CanvasView, Listener {
if (!shape) return;

if (text.node.style.display === 'none') return; // wrong transformation matrix
const { textFontSize, textPosition } = this.configuration;
const { textFontSize } = this.configuration;
let { textPosition } = this.configuration;
if (shape.type === 'circle') {
// force auto for skeleton elements
textPosition = 'auto';
}

text.untransform();
text.style({ 'font-size': `${textFontSize}px` });
Expand All @@ -2569,11 +2574,13 @@ export class CanvasViewImpl implements CanvasView, Listener {
if (textPosition === 'center') {
let cx = 0;
let cy = 0;
if (shape.type === 'rect') {
// for rectangle finding a center is simple
if (['rect', 'image'].includes(shape.type)) {
// for rectangle/mask finding a center is simple
cx = +shape.attr('x') + +shape.attr('width') / 2;
cy = +shape.attr('y') + +shape.attr('height') / 2;
} else if (shape.type === 'ellipse') {
} else if (shape.type === 'g') {
({ cx, cy } = shape.bbox());
} else if (['ellipse'].includes(shape.type)) {
bsekachev marked this conversation as resolved.
Show resolved Hide resolved
// even simpler for ellipses
cx = +shape.attr('cx');
cy = +shape.attr('cy');
Expand Down