fix: render compressedDepth images instead of a broken image icon - #1256
Open
HibridOPT wants to merge 3 commits into
Open
fix: render compressedDepth images instead of a broken image icon#1256HibridOPT wants to merge 3 commits into
HibridOPT wants to merge 3 commits into
Conversation
`compressed_depth_image_transport` wraps depth images in a single channel PNG, which the app currently has no way to read. `createImageBitmap` is not usable for it: the browser always hands back 8 bit RGBA samples, which would throw away half the precision of the 16 bit depth values. This decoder keeps the samples intact. It handles the subset of PNG that OpenCV's `imencode` produces for a single channel `Mat` - non-interlaced, 8 or 16 bit grayscale - which is what every ROS depth publisher goes through, and rejects anything outside that with a specific message. Inflate uses the platform `DecompressionStream`, so no new dependency is needed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CvJLEJUpndwivJrV9yUY7G
A `compressedDepth` payload is a 12 byte `ConfigHeader` followed by the PNG, not a browser media type. Unpacking it into a raw image lets it render through the existing raw image path, so the panel's color mode settings apply exactly as they do for an uncompressed depth topic. `16UC1` carries depth directly in millimetres. `32FC1` has its inverse depth quantization undone with the parameters from the header, where a zero sample marks a pixel the publisher could not measure. The RVL codec is reported as unsupported rather than failing obscurely. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CvJLEJUpndwivJrV9yUY7G
`decodeCompressedImageToBitmap` builds a media type by prefixing "image/" to the message format, so a depth image became "image/16UC1; compressedDepth png", which no browser can decode - hence the broken image icon in the Image and 3D panels. Those messages are now routed to the compressedDepth conversion and decoded through the raw image path. The work runs in the existing image decoder worker so the inflate and per-pixel conversion stay off the main thread. Fixes lichtblick-suite#1241 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CvJLEJUpndwivJrV9yUY7G
WalkthroughChangesCompressed depth rendering
Estimated code review effort: 4 (Complex) | ~45 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant ImageRenderable
participant WorkerImageDecoder
participant WorkerImageDecoderWorker
participant CompressedDepthDecoder
ImageRenderable->>WorkerImageDecoder: decode compressedDepth image
WorkerImageDecoder->>WorkerImageDecoderWorker: forward image, format, and settings
WorkerImageDecoderWorker->>CompressedDepthDecoder: decode PNG payload to RawImage
CompressedDepthDecoder-->>WorkerImageDecoderWorker: return RawImage
WorkerImageDecoderWorker-->>ImageRenderable: return ImageData
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Contributor
|
Hi @HibridOPT Please allow us a little time for a first human-review. Our automated worflows were triggered and there are some Thanks for your contribution. 😸 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



User-Facing Changes
compressedDepthimage topics now render in the Image and 3D panels, with the panel's existing depth color modes applying to them, instead of showing a broken image icon.Description
Fixes #1241.
decodeCompressedImageToBitmapbuilds a media type by prefixingimage/to the message format, so a depth image becameimage/16UC1; compressedDepth png— which no browser can decode, hence the broken image icon.Three commits:
compressed_depth_image_transportwraps depth images in a single-channel PNG.createImageBitmapis not usable here: the browser always hands back 8-bit RGBA samples, throwing away half the precision of 16-bit depth values. This decoder keeps the samples intact. It handles the subset of PNG that OpenCV'simencodeproduces for a single-channelMat— non-interlaced, 8- or 16-bit grayscale — which is what every ROS depth publisher goes through, and rejects anything outside that with a specific message. Inflate uses the platformDecompressionStream, so no new dependency.compressedDepthpayload is a 12-byteConfigHeaderfollowed by the PNG, not a browser media type. Unpacking it into a raw image lets it render through the existing raw image path, so the panel's color mode settings apply exactly as they do for an uncompressed depth topic.16UC1carries depth directly in millimetres;32FC1has its inverse depth quantization undone with the parameters from the header, where a zero sample marks a pixel the publisher could not measure. The RVL codec is reported as unsupported rather than failing obscurely.Checklist
Summary by CodeRabbit
New Features
compressedDepthimages in 3D views.Tests