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

camshift Python example not working with kinetic

asked 2017-06-15 09:47:29 -0600

burtbick gravatar image

Hi, Had the 'ROS by example' camshift example working fine with Indigo on Linux Mint 17.1, including doing pan and tilt head tracking.

I have recently updated to kinetic and the python camshift based node starts up with no errors, and creates the windows but nothing in the windows except a copy of the upper left section of the desktop. I dropped back to the camshift example I started with and that behaves the same way.

It appears that the image processing callback is only called once at startup, with a frame width of None, so that is probably the issue. But I haven't been able to determine the cause yet.

I'm able to rosrun image_view image_view image:/camera/rgb/image_raw to view the output of the camera and that works fine. Also a C++ camshift example works fine and I can select the object and track it fine in the C++ version.

But the Python version is a non-starter. Has anyone else seen this? Did I miss installing something, or is this a subtle API difference between Indigo and Kinetic?

Thanks, Burt

ros-kinetic-vision-opencv is the newest version.

edit retag flag offensive close merge delete


A little more information. I found a camshift python example (not integrated with ROS) and that works fine using cv2.VideoCapture() to access the WebCam.

burtbick gravatar image burtbick  ( 2017-06-15 10:17:30 -0600 )edit

My code is NOT getting /camera/rgb/image_raw topic messages even though I can use rostopic echo to see that the messages ARE flowing from the usb_cam driver.

burtbick gravatar image burtbick  ( 2017-06-15 10:18:59 -0600 )edit

More info. launch file is doing <remap from="input_rgb_image" to="/camera/rgb/image_raw"/> Code is doing: self.image_sub = rospy.Subscriber("input_rgb_image", Image, self.image_callback, queue_size=1)

burtbick gravatar image burtbick  ( 2017-06-15 11:37:04 -0600 )edit

But with the sub to input_rgb_image the input_rgb_image topic does not appear in the topic list. I guess I'll have to move back to Indigo and try to figure out what is broken with this on kinetic

burtbick gravatar image burtbick  ( 2017-06-15 11:38:24 -0600 )edit

Is the code you're using hosted somewhere, and you could provide a link?

lucasw gravatar image lucasw  ( 2017-06-15 12:16:39 -0600 )edit

Code is not currently hosted anywhere external. I've done some more digging and there is something strange happening. the processing function is sub-classed and when it is called under kinetic it doesn't see the correct class members and as mentioned I'm not getting video topic data

burtbick gravatar image burtbick  ( 2017-06-15 13:04:15 -0600 )edit

Since this fails with the unmodified ROS by example code here's a github URL to the code. You can try the rbx1_vision cv_bridge_demo.launch to see if you can duplicate what I'm seeing.

burtbick gravatar image burtbick  ( 2017-06-15 13:15:29 -0600 )edit

A bit more information. Something appears to have changed between what I have with Indigo and Kinetic. That is in the callback imshow() doesn't appear to return. Of course waitKey(n) has to be called after imshow() but since imshow() doesn't return that can't happen.

burtbick gravatar image burtbick  ( 2017-06-15 18:01:11 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-06-16 16:11:20 -0600

burtbick gravatar image

This may not be the complete answer to what is going on, but what I did to resolve the issue was to move the creation of the named openCV window(s) to the callback method. I set a flag in the object __init__ function and if that flag is set when the callback function executes I create the windows, and perform the associated initialization on the windows, clear the flag so the creation only happens one time.

This has things working again, both imshow() and waitKey() work as before.

I need to apply this change to my original Python code to make sure that there is nothing else similar that I need to do, like maybe things related to the mouse.

But if you have a similar issue with Kinetic and OpenCV you might try a similar approach.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-06-15 09:47:29 -0600

Seen: 355 times

Last updated: Jun 16 '17