How can I publish I420 image data as sensor_msgs/Image? (Image transport plugin)
From gstreamer v4l2src plugin, I get gstreamer buffer data(I420).
How can I publish it as sensor_msgs/Image? (Image transport plugin)
So I have a pointer to data. I know Height and width of final image. Anyways, I420 data arrangement mentioned in this post. (Just to indicate pixel arrangements, whole post in not important).
image_transport::Publisher pub = it.advertise("out_image_base_topic", 1);
mat = cv::Mat((height*3)/2, width, CV_8UC1, map.data);
sensor_msgs::ImagePtr msg = cv_bridge::CvImage(std_msgs::Header(), "i420", mat).toImageMsg();
pub.publish(msg);
Is it the correct way? Or first I have to convert image from I420 to BGR?
cvtColor(mat, mat, CV_YUV2BGR_I420, 3);