image.publish() via image transport
Hello,
I have troubles to publish images via image_transport.
This is what I want to do:
right_image_.header.frame_id = left_image_.header.frame_id = config_.frame_id;
left_image_.header.stamp = right_image_.header.stamp=image->header.stamp;
left_image_.height = right_image_.height=image->height;
left_image_.width = right_image_.width=image->width;
left_image_.encoding = right_image_.encoding = image->encoding;
//Split image into left image and right image
left_image_.step = right_image_.step = image->step;
int image_size = image->height*image->step;
left_image_.data.resize(image_size);
right_image_.data.resize(image_size);
memcpy(&right_image_.data[0], &image->data[0], image_size);
// the image of right camera is the first half of the deinterlaced image.
memcpy(&left_image_.data[0], &image->data[image_size], image_size);
// the image of left camera is the second half of the de interlaced image.
// Publish via image_transport
left_image_pub_.publish(left_image_, ci);
right_image_pub_.publish(right_image_, ci);
But publish method only admit
void publish(const sensor_msgs::ImageConstPtr& image, const sensor_msgs::CameraInfoConstPtr& info) const;
And I have only sensor_msgs::Image.
How can I convert from sensor_msgs::Image to sensor_msgs::ImageConstPtr ??
Thanks a lot.
Best regards