Skip to content

Conversation

@yannik131
Copy link

Resolves Issue #1232 by taking a screenshot of the map if the image is tiled.

@mzur mzur linked an issue Nov 19, 2025 that may be closed by this pull request
@yannik131
Copy link
Author

@mzur
kleines Problem: Ich hatte aus Versehen die .onnx-Datei mit auf remote gepusht. Ist nicht so leicht, die aus der History wieder rauszukriegen (man müsste die gesamte History mit git filter-repo o. ä. umschreiben). Also würde ich alles löschen und nur die Codeänderungen wieder reinkopieren mit

cp -r resources ~/backup/resources
git reset --hard <last commit before my changes>
git push --force
cp -r ~/backup/resources resources
git add .
git commit -m "Made labelbot work for tiled images"
git push

Dann geht zwar meine History (5 commits -> 1 commit) verloren, aber das ist nicht so schlimm denke ich. Passt das so? Dann mach ich das morgen und dann kann die PR auch reviewed werden.

@mzur
Copy link
Member

mzur commented Nov 20, 2025

Ja das passt so, kein Problem 👍

@mzur
Copy link
Member

mzur commented Nov 20, 2025

btw this is our commit message style guide in case you are interested: https://chris.beams.io/git-commit

Since tiled images are transmitted in parts, no underlying image can be
directly accessed. Instead, a screenshot of the map is taken and cropped
according to the selection.
@yannik131 yannik131 marked this pull request as ready for review November 20, 2025 13:11
@yannik131
Copy link
Author

@mzur I changed the PR to ready for review, but can't select a reviewer or request a review. It's ready though.

@mzur mzur self-requested a review November 20, 2025 13:28
@mzur
Copy link
Member

mzur commented Nov 20, 2025

Please resolve the linter errors. Run it locally with npm run lint.

@yannik131
Copy link
Author

I resolved them, but the pipeline doesn't seem to run automatically @mzur

Copy link
Member

@mzur mzur left a comment

Choose a reason for hiding this comment

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

This works great already! My comments are mostly about stylistic issues.

Removed unneeded constructs for the labelbot images (TILEDIMAGES state,
tempCanvas, etc.)
@yannik131
Copy link
Author

I made the changes as requested @mzur, ready for review again.

@mzur mzur self-requested a review December 1, 2025 10:23
Copy link
Member

@mzur mzur left a comment

Choose a reason for hiding this comment

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

I've merged the current master.

I noticed that there was a slight delay when the labelbotImage is generated. I suggested some optimizations below.

Comment on lines 101 to 103
makeBlob(event.context.canvas).then(blob => {
resolve(createImageBitmap(blob));
});
Copy link
Member

Choose a reason for hiding this comment

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

makeBlob and createImageBitmap are quite slow (600-700 ms on my machine). We don't need a blob or an ImageBitmap object, though, and can use the trimmed canvas directly (200 ms on my machine):

Suggested change
makeBlob(event.context.canvas).then(blob => {
resolve(createImageBitmap(blob));
});
resolve(trimCanvas(event.context.canvas));

makeBlob can be moved back to the screenshotButton then.

Most of the remaining 200 ms was used by trimCanvas. This can be improved with an early return (see below).

Copy link
Author

Choose a reason for hiding this comment

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

I think this doesn't work because the canvas is shared between the various layers. After the tiledImageLayer had its postrender event, the next layers will write to the same canvas and annotations will be visible on it. This will result in annotations being visible in the canvas sent to labelbot (unless the labelbot code executes first, which it probably won't). Tested it briefly by displaying the canvas after the postrender event and I did see the annotations on it.
However, if the necessary code for getting the relevant section from the canvas is put directly in the postrender callback, it should work since it's synchronous. I'll try that out and get back to you.

Copy link
Author

Choose a reason for hiding this comment

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

I moved the screenshot code into createLabelbotImageFromTiledImage to handle the canvas synchronously directly after the postrender event and now it works.

Copy link
Member

Choose a reason for hiding this comment

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

Ok! Just let me know when this is ready to review again.

Copy link
Author

Choose a reason for hiding this comment

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

It's already ready. I applied all your suggestions and tested it locally. Everything seems to works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LabelBOT for tiled images

2 participants