Skip to content

Commit

Permalink
fix: LEAP-439: Add maskData exporting into new MIG serialization appr…
Browse files Browse the repository at this point in the history
…oach (#5246)

* [submodules] Build static HumanSignal/label-studio-frontend

Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7413835114

* [submodules] Build static HumanSignal/label-studio-frontend

Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7414040859

* [submodules] Build static HumanSignal/label-studio-frontend

Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7415324369

* [submodules] Build static HumanSignal/label-studio-frontend

Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7415843866

* [submodules] Copy src HumanSignal/label-studio-frontend

Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7466346141

* [submodules] Build static HumanSignal/label-studio-frontend

Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7466346141

* [submodules] Copy src HumanSignal/label-studio-frontend

Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7466386615

* [submodules] Build static HumanSignal/label-studio-frontend

Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7466386615

* ci: Build frontend

Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7466431342

* [submodules] Copy src HumanSignal/label-studio-frontend

Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7466931328

* [submodules] Build static HumanSignal/label-studio-frontend

Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7466931328

---------

Co-authored-by: Sergey <gondragos@gmail.com>
Co-authored-by: robot-ci-heartex <robot-ci-heartex@users.noreply.github.com>
Co-authored-by: Sergey <sergey.koshevarov@heartex.com>
  • Loading branch information
4 people authored Jan 9, 2024
1 parent d0c03ce commit b6da213
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion label_studio/frontend/dist/lsf/js/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion label_studio/frontend/dist/lsf/js/main.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions label_studio/frontend/dist/lsf/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"message": "fix: LEAP-461: Fix displaying conditions for comments tab",
"commit": "083812f3291b4b85845841e4ca58126e6d12e50e",
"message": "fix: LEAP-439: Add maskData exporting into new MIG serialization approach",
"commit": "a3e4f43f823890cbc40f712634defbff003124dd",
"branch": "master",
"date": "2024-01-09T18:54:17Z"
"date": "2024-01-09T21:10:34Z"
}
2 changes: 1 addition & 1 deletion web/dist/libs/editor/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/editor/main.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const AnnotationTab = observer(({ store }) => {

<Elem name="content">
<Comments
annotationStore={as}
commentStore={store.commentStore}
cacheKey={`task.${store.task.id}`}
/>
Expand Down
26 changes: 16 additions & 10 deletions web/libs/editor/src/regions/BrushRegion.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,19 +228,24 @@ const Model = types
let pathPoints,
cachedPoints,
lastPointX = -1,
lastPointY = -1;
lastPointY = -1,
maskImage;

return {
afterCreate() {
// if ()
// const newdata = ctx.createImageData(750, 937);
// newdata.data.set(decode(item._rle));
// const dec = decode(self._rle);
// self._rle_image =
// item._cached_mask = decode(item._rle);
// const newdata = ctx.createImageData(750, 937);
// newdata.data.set(item._cached_mask);
// var img = imagedata_to_image(newdata);
self.updateMaskImage();
},

updateMaskImage() {
if (self.maskDataURL) {
if (!maskImage) maskImage = new window.Image();

maskImage.src = self.maskDataURL;
}
},

getMaskImage() {
return maskImage;
},

setLayerRef(ref) {
Expand Down Expand Up @@ -349,6 +354,7 @@ const Model = types
annotation.startAutosave();

self.maskDataURL = maskDataURL;
self.updateMaskImage();

self.notifyDrawingFinished();

Expand Down
7 changes: 7 additions & 0 deletions web/libs/editor/src/utils/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ function exportRLE(region) {
ctx.putImageData(imageData, 0, 0);
}

const maskImage = region.getMaskImage?.();

if (maskImage) {
// Apply maskDataURL to existing image data
ctx.drawImage(maskImage, 0, 0);
}

// If the region was changed manually, we'll have access to user tuoches
// Render those on the canvas after RLE
if (region.touches.length > 0) {
Expand Down

0 comments on commit b6da213

Please sign in to comment.