0
$\begingroup$

Rosanswers logo

Hello,

I try to setup a Service which provides single images out of an image_transport stream to a client requesting an image. I found this Question 42909 (Karma not sufficient to post links, sorry.) which is in principal what I need.

answers.ros.org/question/42909/how-can-i-use-a-servicerequest-to-capture-a-single-callback-from-a-subscription/

Since I'm new to ROS and the example is simplified I'm stuck at the point where the image is presented to the client. What I would need to know is:

  1. How does the srv file look like to use the example. (If a srv file is needed at all)
  2. How can I actually get access to the image on client side to do image processing on it. In the example this part is simplified with the comment: read_grab() ?

I searched ROS answers for hours with no success so I hope somebody understands my problem description and is willing to help.

thanks in advance HXP2


Originally posted by HXP2 on ROS Answers with karma: 13 on 2014-04-01

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You could have a look at this node, which does something similar for kinect data. You should be able to take the general idea and adapt it to your needs with only color images instead of kinect data: https://github.com/SharedAutonomyToolkit/shared_autonomy_perception/blob/hydro-devel/assemble_kinect/src/assemble_kinect.cpp

The .srv file used in for this node is here: https://github.com/SharedAutonomyToolkit/shared_autonomy_perception/blob/hydro-devel/shared_autonomy_msgs/srv/KinectAssembly.srv

I'm not saying this is the best solution, but maybe it helps.

Edit:

In response to your clarification of what you want to do: You could build a node along the following lines:

  1. Create class to implement your node. In particular you have one Image message member variable to store the latest received input image, and you have another image object as member variable (message or cv::Mat or whatever) that will contain the first image without the laser line.
  2. Subscribe to the image topic, and in the callback always save the the incoming image to the corresponding member variable
  3. Subscribe to some sort of command topic (maybe of type std_msgs/String) with which you tell your node to store the current image as the first image. In the callback you copy the one member variable to the other
  4. When you receive a second command (you could either count the commands, or use different strings or whatever), you take the current image and compare it to the one you saved on the first command.

For help on converting between ROS image messages and OpenCV images, see http://wiki.ros.org/cv_bridge/Tutorials/UsingCvBridgeToConvertBetweenROSImagesAndOpenCVImages


Originally posted by demmeln with karma: 4306 on 2014-04-02

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.