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 -0500
Seen: 11,951 times
Last updated: May 13 '22
what is the distance unit of /camera/depth/image_raw
Does anyone have a Simulink library model to publish to ROS
Image overlapped with Kinect [closed]
how to get the image topic from the other computer with WiFi
ros2 megapixel image pub/sub cpu usage is very high
Using ROS to read images over TCP/IP
Could NOT find openni [closed]
Data Definition RGB16 Image Encoding
Did you ever get an example working that you care to share?