black_image_publisher.cpp
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <image_transport/image_transport.h>
00003 #include <cv_bridge/cv_bridge.h>
00004 #include <opencv2/highgui/highgui.hpp>
00005 #include <opencv2/imgproc/imgproc_c.h>
00006 #include <sensor_msgs/Image.h>
00007 
00008 int main(int argc, char** argv) {
00009 
00010   ros::init(argc, argv, "black_image_publisher");
00011   ros::NodeHandle nh;
00012   image_transport::ImageTransport it(nh);
00013   image_transport::Publisher pub = it.advertise("black_image", 1);
00014   
00015   //sensor_msgs::ImagePtr msg = sensor_msgs::CvBridge::cvToImgMsg(img, "bgr8");
00016   cv_bridge::CvImage cvb;
00017         cvb.encoding = "8UC3";
00018         //cvb.header = 
00019   
00020   ros::Rate loop_rate(1);
00021   
00022   ROS_INFO("Black image publisher started.");
00023   
00024   while (nh.ok()) {
00025   
00026     cvb.image = cv::Mat::zeros(480, 640, CV_8UC3);
00027     cv::randn(cvb.image,20,10);
00028   
00029     sensor_msgs::Image::Ptr msg = cvb.toImageMsg();
00030   
00031     pub.publish(msg);
00032     ros::spinOnce();
00033     loop_rate.sleep();
00034   }
00035 
00036 
00037 }


srs_user_tests
Author(s): SRS team
autogenerated on Sun Jan 5 2014 12:14:04