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

Revision history [back]

I managed to sort it out the following way, using this answer as a reference http://answers.ros.org/question/9765/how-to-convert-cvmat-to-sensor_msgsimageptr/?answer=14282#post-id-14282:

cv::WImageBuffer3_b image(
                    cvLoadImage(filePath.c_str(), CV_LOAD_IMAGE_COLOR));
            cv::Mat imageMat(image.Ipl());


            cv_bridge::CvImage out_msg;
            out_msg.encoding = sensor_msgs::image_encodings::BGR8; 
            out_msg.image    = imageMat;
            out_msg.header.seq = i;
            out_msg.header.frame_id = i;
            out_msg.header.stamp = ros::Time::now();

            ci->header.seq = i;
            ci->header.frame_id = i;
            ci->header.stamp = out_msg.header.stamp;

            pub.publish(out_msg.toImageMsg(), ci);

I managed to sort it out the following way, using this answer as a reference http://answers.ros.org/question/9765/how-to-convert-cvmat-to-sensor_msgsimageptr/?answer=14282#post-id-14282 :

cv::WImageBuffer3_b image(
                    cvLoadImage(filePath.c_str(), CV_LOAD_IMAGE_COLOR));
            cv::Mat imageMat(image.Ipl());


            cv_bridge::CvImage out_msg;
            out_msg.encoding = sensor_msgs::image_encodings::BGR8; 
            out_msg.image    = imageMat;
            out_msg.header.seq = i;
            out_msg.header.frame_id = i;
            out_msg.header.stamp = ros::Time::now();

            ci->header.seq = i;
            ci->header.frame_id = i;
            ci->header.stamp = out_msg.header.stamp;

            pub.publish(out_msg.toImageMsg(), ci);