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

RGB order flipped when using cam2image with showimage #612

Open
jjd9 opened this issue May 6, 2023 · 2 comments · May be fixed by #623
Open

RGB order flipped when using cam2image with showimage #612

jjd9 opened this issue May 6, 2023 · 2 comments · May be fixed by #623
Assignees

Comments

@jjd9
Copy link

jjd9 commented May 6, 2023

Bug report

Required Info:

  • Operating System:
    • Ubuntu 22.04 (Jammy)
  • Installation type:
    • Debian apt install (binaries?)
  • Version or commit hash:
    • ros-iron-image-tools/jammy,now 0.27.0-2jammy.20230429.031022 amd64
  • DDS implementation:
    • tested with Fast-RTPS and RTI Connext
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

Open two terminals and source the ros2 space in each (i.e. source /opt/ros/iron/setup.bash)

In terminal 1, run the cam2image executable

ros2 run image_tools cam2image --ros-args -p show_camera:=true

In terminal 2, run the showimage executable

ros2 run image_tools showimage

Expected behavior

The image being published and displayed by cam2image matches the image displayed by showimage.

Actual behavior

cam2image reads a BGR image from the camera, publishes it as a CV_U8C3, cv::Mat image, which does not preserve the channel ordering information.
showimage receives the image and assumes that since it is a CV_U8C3, cv::Mat, it should convert it from RGB to BGR. But since that is not true, the result is an image whose channel ordering is flipped.

Here is the output I am getting (Left image: cam2image visual, Right image: showimage visual)

image

Thank you for your time! (-:

@Yadunund Yadunund added this to To do in Iron Irwini via automation May 9, 2023
@Yadunund
Copy link
Member

Yadunund commented May 9, 2023

I encounter this problem as well. Perhaps the solution is to add a parameter to let users override the encoding in cam2image/showimage. Somewhat similar to ros-perception/vision_opencv#505

@EwingKang
Copy link

I encountered a similar problem with the ros2 run image_tools showimage tool. The source image is a ROS image converted from cv_bridge::CvImage, with proper "bgr8" desgination. The RVIZ can display the image correctly while the showimage tool shows reversed R-B channel.

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 a pull request may close this issue.

3 participants