ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Passed senesor_msgs Image getting distored while displaying by openCV

asked 2013-09-12 02:58:22 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I have published an image from one node and then i want to subscribe that image in my second node. But after subscribing it in the second node, when i try to store it in cv::Mat image then, it get distorted.

The patchImage in the following code is distored. there are some horizontal lines and four images of the same image merged.

An overview of my code is following.

        im.header.stamp = time;
        im.width = width;
        im.height = height;
        im.step = 3*width;
        im.encoding = "rgb8";


second_node_imageCallBack(const sensor_msgs::ImageConstPtr& msg)
       cv::Mat patchImage;
       cv_bridge::CvImagePtr cv_ptr;

                cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::RGB8); //

        catch (cv_bridge::Exception& e)
                ROS_ERROR("cv_bridge exception: %s", e.what());

        imshow("Received Image", patchImage); //This patchImage is distored
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-10-15 08:15:41 -0500

tfoote gravatar image

Are you sure you have the upstream encoding right? That sounds like it's getting interlaced due to wrong step size. A picture would help.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2013-09-12 02:58:22 -0500

Seen: 168 times

Last updated: Oct 15 '13