Repository navigation
fix: ROSBag keeps the BGR color order of a CompressedImage unless told otherwise - #315
Open
petercorke wants to merge 2 commits into
Open
petercorke wants to merge 2 commits into
petercorke wants to merge 2 commits into
Conversation
…d otherwise A compressed image is decoded by OpenCV as BGR, but the code replaced the color order it had worked out with the colororder argument, which is None by default, so the image was labelled R:G:B and a pure red JPEG read back as blue. A per-topic dict also dropped the order of the topics it did not list. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 20 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This branch has not been deployed
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.
ROSBaglabelled everysensor_msgs/CompressedImageas R:G:B, although OpenCV decodes the image as BGR. So a pure red JPEG came out as pure blue by default. The code worked out the right order (bgr,bgraor none for greyscale) and then replaced it with thecolororderargument, which isNoneunless given. A per-topic dict also dropped the order of the topics it did not list.The color order of a compressed image is now what the decoder gave, unless
colororderis a string (used for every topic) or a dict with an entry for that topic. Passingcolororder="bgr"already worked around it.I found it by checking with an independent encoder: the new tests encode with Pillow, not OpenCV, so they do not depend on the decoder they check. 7 new tests in
tests/test_ros_compressed_colororder.py; 4 of them fail without the fix. The 446 ROS tests pass and mypy is clean.Behavior change to be aware of: compressed images from a bag now come out as
B:G:R, so code that relied on the old (wrong)R:G:Blabel will see the planes the other way round. They were swapped before.An AI assistant (Claude Code) wrote this change.
🤖 Generated with Claude Code