ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

movement detection in ROS

asked 2015-05-26 08:09:57 -0600

Diego gravatar image

Hello Everyone, I tried a program on OpenCV about movement detection and It works pretty well since it's capturing 2 camera frames and making differentiation between them (from image to grayscale then threshold then absolute difference plus other variables like the sensitivity of the differentiation), however when I try to move the same program to ROS it's not working,

My assumption about this is that when I use image transport nodes, the image callback function just sends one image per parameter and then the comparison between both frames would be the same. can you guys please suggest me something I could use?... I don't have any idea about what to do and I checked in Internet and didn't find anything.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-05-27 03:48:46 -0600

daenny gravatar image

I guess you could create a global "image" variable and then if the variable is not set yet, just use the callback to store the variable. If the variable is set, use the callback you compare the new image with the stored image and afterwards set the saved image to the new image.

Some untested python pseudocode:

def image_cb(msg):
    global old_img
    if old_img is None:
         old_img = msg
    movement_result = compare_imgs(old_img, msg)
    old_img = msg
edit flag offensive delete link more


Hello, thanks for your answers. I had done something similar to this and it worked.

Diego gravatar image Diego  ( 2015-06-03 08:35:33 -0600 )edit

Question Tools

1 follower


Asked: 2015-05-26 08:09:57 -0600

Seen: 271 times

Last updated: May 27 '15