0
$\begingroup$

Rosanswers logo

Hello,

I try to realize image processing with ROS and opencv, and I follow the tutorial of cvBridge. Then I really want to know, whether it is true that we can only do the image processing in the callback function of subscribe message? Is there another way?

As for my experiment, I have realize the image processing with the camera on my PC, then I try to wotk with ROS image,however, there are always problems. So if there is other ways? I don't want to use the callback function to realize image processing.....


Originally posted by anthonyli on ROS Answers with karma: 11 on 2013-05-28

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

ROS is a callback-based system, so on that level, the answer is that you have to do all of the processing in the callback. You can, of course, work around this by using the callback to store the image somewhere, and the working on it later, or in another thread, or something like that.

What would help people answer your question, though, is an explanation of why you don't want to do the processing in the callback function. Without knowing what you want to do, it's hard to offer concrete advice.


Originally posted by Bill Smart with karma: 1263 on 2013-05-28

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by SL Remy on 2013-05-28:
In the other question it sounded like there were callback for user input as well as callbacks from the image message that were confusing the OP http://answers.ros.org/question/63595/ros-iamge-to-opencv-image-and-image-processing/?answer=63774#post-id-63774

Comment by Bill Smart on 2013-05-28:
Didn't see that bit. I can reopen the other question, if you think it's suitably distinct.

Comment by SL Remy on 2013-05-28:
I think it's essentially the same question, just a little detail came out in the comments.

Comment by anthonyli on 2013-05-28:
Thank you for your answer! In my program, I don't want to deal image processing each time receive a image and the image process for each frame maybe 100ms. So when I try the webcam, I grab the image when I want to use, now I am trying to do that with ROS… Thank you!

Comment by anthonyli on 2013-05-29:
I am going to be crazy and so worry about my program. Compared with my program of webcam, there only difference in getting the image data. In order to say clearly, let me make an example. I try to draw several boxes in the window of image.

Comment by anthonyli on 2013-05-29:
When I deal with webcam, I can draw several boxes in the window and name them: "0", "1", "2"...When I deal with ROS, I cam only draw the box "0" and suddenly it will disappear, then I draw again, it will show box "0" again and disapper again.It seems it will refresh. The problem it's like this way.

Comment by SL Remy on 2013-05-29:
Hello Anthony, you can choose the rate at which the camera messages are published. You can also choose when you update the images that you're merging (I assume that you're using something like http://dasl.mem.drexel.edu/~noahKuntz/openCVTut2.html#Step%202)

Comment by anthonyli on 2013-05-29:
I have tried several ways with it all the day, and I will try to set the loop_rate as you said! Moreover, if you'd like, you could see my code(http://www.zlzdesign.com/pet_drone.cpp) and help me to find the problem! Anyway, you really do me a favor! I will make effect to make it not refresh!

$\endgroup$

Your Answer

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