camshift Python example not working with kinetic
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 imageview imageview 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.
Asked by burtbick on 2017-06-15 09:47:29 UTC
Answers
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.
Asked by burtbick on 2017-06-16 16:11:20 UTC
Comments
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.
Asked by burtbick on 2017-06-15 10:17:30 UTC
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.
Asked by burtbick on 2017-06-15 10:18:59 UTC
More info. launch file is doing
Code is doing: self.image_sub = rospy.Subscriber("input_rgb_image", Image, self.image_callback, queue_size=1)
Asked by burtbick on 2017-06-15 11:37:04 UTC
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
Asked by burtbick on 2017-06-15 11:38:24 UTC
Is the code you're using hosted somewhere, and you could provide a link?
Asked by lucasw on 2017-06-15 12:16:39 UTC
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
Asked by burtbick on 2017-06-15 13:04:15 UTC
Since this fails with the unmodified ROS by example code here's a github URL to the code. https://github.com/pirobot/rbx1.git You can try the rbx1_vision cv_bridge_demo.launch to see if you can duplicate what I'm seeing.
Asked by burtbick on 2017-06-15 13:15:29 UTC
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.
Asked by burtbick on 2017-06-15 18:01:11 UTC
This problem is why I thought I was not getting the raw_image messages. Everything looks OK as far as the frame image data (converted from ros to opencv). So I need to figure out why imshow() is hanging in this context. In non-callback code imshow() appears to work fine.
Asked by burtbick on 2017-06-15 18:02:56 UTC
Last bit of data. Looking closely on Indigo I'm using Python 2.7.6 with Open CV 3.1.0 But on Kinetic it is Python 2.7.12 and OpenCV 3.2.0-dev. So I suspect the issue is with Open CV 3.2.0-dev so I've got to dig into it more to figure out what has changed between the two OpenCV 3.x versions.
Asked by burtbick on 2017-06-15 19:32:07 UTC