Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 121

Publishing camera_info messages

$
0
0
Hello everyone I am using Ubuntu 14.04 and Ros Indigo. I am trying to make the tutorial on camera_calibration (http://wiki.ros.org/camera_calibration/Tutorials/MonocularCalibration) To do this they ask me to have these 2 topics publishing data: /camera/camera_info /camera/image_raw I was using the image_transport_tutorials publisher video (http://wiki.ros.org/image_transport/Tutorials/PublishingImages) Additional to this, from this question http://answers.ros.org/question/11361/how-to-publish-sensor_msgscamerainfo-messages/ I added 4 lines and my program is publishing camera info, however I always receive this message ('Waiting for service', '/camera/set_camera_info', '...') Service not found I will copy here the image_transport_tutorials publisher used... Could someone please tell me how can I make this code to publish camera information? (or how to publish information about the camera I am using) #include #include #include #include #include // for converting the command line parameter to integer int main(int argc, char** argv) { // Check if video source has been passed as a parameter if(argv[1] == NULL) return 1; ros::init(argc, argv, "image_publisher"); ros::NodeHandle nh; image_transport::ImageTransport it(nh); image_transport::Publisher pub = it.advertise("camera/image", 1); ros::Publisher pub_info_camera = nh.advertise("camera/camera_info", 1); // sensor_msgs::CameraInfo info_camera; // // Convert the passed as command line parameter index for the video device to an integer std::istringstream video_sourceCmd(argv[1]); int video_source; // Check if it is indeed a number if(!(video_sourceCmd >> video_source)) return 1; cv::VideoCapture cap(video_source); // Check if video device can be opened with the given index if(!cap.isOpened()) return 1; cv::Mat frame; sensor_msgs::ImagePtr msg; ros::Rate loop_rate(5); while (nh.ok()) { cap >> frame; // Check if grabbed frame is actually full with some content if(!frame.empty()) { msg = cv_bridge::CvImage(std_msgs::Header(), "bgr8", frame).toImageMsg(); info_camera.header.stamp = ros::Time::now(); // pub_info_camera.publish(info_camera); // pub.publish(msg); cv::waitKey(1); } ros::spinOnce(); loop_rate.sleep(); } } Thanks in advance.

Viewing all articles
Browse latest Browse all 121

Trending Articles