What's the best library for video capture in Python on linux?
I want to write an application to video capture from web-cams in linux. Is there a python library to do that?
You should look at Gstreamer and its Python bindings. Here http://pygstdocs.berlios.de/pygst-tutorial/webcam-viewer.html is some sample code to display video from a webcam. To record the video you would have to change the pipeline definition from autovideosink
to an encoder and filesink.
You could look into WebCamsPy , which appears to do what you are asking.
Also, see a related question, which asks more generally for windows and Linux but might still help you.
OpenCV is the easiest thing I've seen. Take a look at this post: http://www.jperla.com/blog/2007/09/26/capturing-frames-from-a-webcam-on-linux/
You can $ sudo apt-get install python-opencv
(I believe), as well as pygame and PIL if you haven't already installed them. Once you have those libraries you can start viewing/saving images - technically if you just want to capture you don't need to use pygame, but it does allow you to also view the images. Technically speaking, the "meat" of the work is done with PIL and opencv, so you can use any type of graphical framework (gtk, tk, wx, qt, etc) that you're familiar with.
I've been trying to do something like this with mine, and I've been getting a crash course in PIL, and it's actually a pretty easy library to use, though I think I'll really need to include numpy for processing in that mix...
Anyway, opencv+PIL == super easy.
链接地址: http://www.djcxy.com/p/46610.html上一篇: 处理数百万次定时(预定)消息的解决方案?