using cv_bridge and converting the cvmat to numpy efficiently
Hello everyone. I wrote a bunch of image tracking in python using the "cv2" API.
I am now trying to plug that into ROS and I noticed that cv_bridge gives me a cvmat object, not a numpy object that I need to use with the cv2 API. I used numpy.asarray() to convert the cvmat to numpy, but this introduces a serious amount of lag into my system.
I wrote a very simple test which takes the output of the cv_bridge and calls cv.ShowImage on it. It works fine. Then I modified it to take the cv_bridge output, convert it to a numpy with asarray() and run cv2.imshow() on it.
The second case had about a second of lag! Is that expected? Is there any way to convert the cvmat to a numpy "in-place" ?
Thanks -s
Thanks for the idea Dan. Yeah I converted my numpy back to a cvmat and called cv.ImageShow and it works fine.. Is there a reason why imshow should be so much slower than ShowImage() though?
My guess would be that what's taking a long time is creating the window initially. Can you get timing for successive calls to imshow? You could also see how long calling cv2.namedWindow takes. At this point it might be better to ask the opencv mailing list.