Displaying Video from webcam in opencv on GTK+
I'm new to this and was wonderin开发者_如何转开发g what i need to do to my open cv code to display using gtk. Does it need to be converted or what?
It's fairly simple to do using Python. Here is a class that I've written to control a webcam using OpenCV and convert the frames to a NumPy array:
https://github.com/ptomato/REP-instrumentation/blob/master/rep/generic/opencv_webcam.py
After that, you can use gtk.gdk.pixbuf_new_from_array()
to create a pixbuf which you can then create a gtk.Image
from. Note that PyGTK needs to be compiled with NumPy support for this to work.
You can also use Matplotlib to display the frame in a GTK user interface. Here's another class that I've written that does that:
https://github.com/ptomato/Beams/blob/4276a1b98d4df2843d3e22b1be99ea0cabb4f6d4/src/CameraImage.py
精彩评论