Unable to display image with cvbridge

asked 2018-05-09 16:34:05 -0500

rsmitha gravatar image


I am reading an image using the cv-bridge API with ROS and I just want to display the image to see what cv_bridge is processing as I need to debug the algorithm. My code is :

static const std::string OPENCV_WINDOW = "Image window";
class abc 
    abc() {  cv::namedWindow(OPENCV_WINDOW); }
    void function();

void function()
    cv_bridge::CvImagePtr cv_ptr(new cv_bridge::CvImage);
    std::vector<cv::Mat> channels;
    std::vector<cv::Mat> a_ch(3);
    cv_ptr->image = cv::imread("jackal_flipped_image.png",CV_LOAD_IMAGE_COLOR);
    cv_ptr->encoding = "bgr8";

The image window comes up but does not show anything. It is just white in color. What am I missing or doing wrong?

Regards, rsmitha.

edit retag flag offensive close merge delete