Hello Everyone, I am using OpenCV 2.9 and ROS Hydro. i used this Publisher for publish image and used Subscriber for subscribing images. I am able to show that image but how to save it in computer?? I Used imwrite like this after imshow()
cv::imwrite("//home//keshav//image.jpg",cv_bridge::toCvShare(msg, "bgr8")->image);
p
Originally posted by KDROS on ROS Answers with karma: 67 on 2014-11-13
Post score: 1
Original comments
Comment by Wolf on 2014-11-13:
Add what happend? Error or something?
Comment by KDROS on 2014-11-14:
there is no error but also It is not saving any images.
I seached in net somewhere i found that I should use latest opencv for that..but i dont want to install that one.
Comment by Wolf on 2014-11-14:
Does the folder "//home//keshav//" exist? Usually it should be "/home/keshav/image.jpg" but that should not matter... Does imwrite return true? It should return true on success...
Comment by KDROS on 2014-11-17:
hoe to check that one..
Comment by Wolf on 2014-11-17:
if ( cv::imwrite("//home//keshav//image.jpg",cv_bridge::toCvShare(msg, "bgr8")->image) ) { ROS_INFO( "Returned true" ); } else { ROS_INFO( "Returned false" ); }
Comment by KDROS on 2014-11-17:
try
{
cv::imshow("view", cv_bridge::toCvShare(msg,"bgr8")->image);
cv_ptr = cv_bridge::toCvCopy(msg, enc::BGR8);
if ( cv::imwrite("//home//keshav//image.jpg",cv_bridge::toCvShare(msg, "bgr8")->image) ) { ROS_INFO( "Returned true2" ); } else { ROS_INFO( "Returned false2" ); }
}
Comment by KDROS on 2014-11-17:
It is neither returning true nor false.. :-(
Comment by KDROS on 2014-11-17:
I have to create ROS nodes, one node can capture images using webcam & 2nd node can publish and third node can subscribe. first am unable to capture also, I can publish and subscribe but imwrite is not working. Mr. Wolf plz share some solid links or code that I can easily execute for this purpose
Comment by KDROS on 2014-11-17:
I have done all these job in C using OpenCV and socket communication but now I have to create in ROS only. One more thing I did in C is Serial commands for FTDI Devices, I have to create node for this also, but i will do it later.first I have to capture and publish. Usb_cam, Uvc_cam i tried but ;'-(
Comment by Wolf on 2014-11-17:
If it does neither return true nor false, the line you've given is not executed; I guess an exception is thrown before that ; how does your catch statement look like ? is it executed?
Comment by KDROS on 2014-11-18:
catch (cv_bridge::Exception& e)
{
ROS_ERROR("Could not convert from '%s' to 'bgr8'.", msg->encoding.c_str());
}
Nothing is printing on screen.
Comment by KDROS on 2014-11-18:
If i wanted to publish different images (multiple images) after sleep, How it is possible