cardboardcode / epd_core

A ROS2 package that accelerates the training and deployment of CV models for industries.
Apache License 2.0
0 stars 0 forks source link

Color RGB image format is flipped in ROS2 Humble #9

Closed cardboardcode closed 2 years ago

cardboardcode commented 2 years ago

Issue Description

The following image is outputted when running default virtual_camera test image with EPD on ROS2 Humble: Screenshot from 2022-08-03 21-21-39

Source of Error

For some reason, the RGB format of incoming sensor_msgs::msg::Image is flipped as shown by the output image.

cardboardcode commented 2 years ago

Narrowed down the issue to the cv_bridge conversion.

sensor_msgs::msg::Image::SharedPtr output_msg =
      cv_bridge::CvImage(std_msgs::msg::Header(), "bgr8", resultImg).toImageMsg();
    visual_pub->publish(*output_msg);
cardboardcode commented 2 years ago

Solution :partying_face:

Include the following line before the the cv_bridge conversion as show above:

cv::cvtColor(resultImg, resultImg, CV_BGR2RGB); // Include this line.

sensor_msgs::msg::Image::SharedPtr output_msg =
      cv_bridge::CvImage(std_msgs::msg::Header(), "bgr8", resultImg).toImageMsg();