publish file to image topic
Hi, I want to publish an image file (i.e. image1.jpg) to an image topic I can display in rviz (/camera/image). Can anyone tell me a simple way to do this?
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
Hi, I want to publish an image file (i.e. image1.jpg) to an image topic I can display in rviz (/camera/image). Can anyone tell me a simple way to do this?
Use opencv imread on the file and then rosbridge to convert to the sensor_msgs/Image format: http://wiki.ros.org/cv_bridge/Tutorials/UsingCvBridgeToConvertBetweenROSImagesAndOpenCVImages
Try out https://github.com/lucasw/image_manip...
rosrun image_manip image_folder_publisher.py _folder:=`pwd`
and there are likely more to be found elsewhere
There is a node for this:
rosrun image_publisher image_publisher /absolute/path.png
This is what I got working in Hydro
#include <ros/ros.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
int main(int argc, char** argv)
{
ros::init(argc, argv, "image_publisher");
ros::NodeHandle nh;
cv_bridge::CvImage cv_image;
cv_image.image = cv::imread("/home/taylor/Pictures/face.jpg",CV_LOAD_IMAGE_COLOR);
cv_image.encoding = "bgr8";
sensor_msgs::Image ros_image;
cv_image.toImageMsg(ros_image);
ros::Publisher pub = nh.advertise<sensor_msgs::Image>("/static_image", 1);
ros::Rate loop_rate(5);
while (nh.ok())
{
pub.publish(ros_image);
loop_rate.sleep();
}
}
Asked: 2013-11-11 04:43:39 -0600
Seen: 12,232 times
Last updated: May 13 '22
image.publish() via image transport
how to publish a topic from kinect in a node?
network pub/sub or messaging example, or documentation?
basic question in understanding publishing and subscribing
Is there a way to compress an Image?
Where is there a canned disparity image to point cloud function? [closed]
TF Frame Convention for Stereo Cameras
Putting a sensor_msgs/Image into a message, getting it back, and converting it for OpenCV?
Camera pose calibration with multiple camera's
Coloring point clouds from images - how to match 3Dpoint/pixel efficiently?
Did you ever get an example working that you care to share?