简体   繁体   English

使用Python 3.X访问网络摄像头

[英]Accessing a webcam with Python 3.X

For a school project I am using a Raspberry Pi to detect certain colours in a webcam image. 对于一个学校项目,我正在使用Raspberry Pi来检测网络摄像头图像中的某些颜色。 However, I can't seem to find any way to access the webcam using Python 3.X. 但是,我似乎找不到使用Python 3.X访问网络摄像头的任何方法。 Are there any libraries out there that work with python 3.X that work for both windows and linux (I'm creating the program on windows 7 but going to be using it on the R-Pi)? 有没有可以在Windows和Linux上都可以使用的适用于python 3.X的库(我正在Windows 7上创建程序,但将在R-Pi上使用它)?

If not, I suppose I could end up settling for Python 2.7 simply because the R-Pi has both versions installed on it (Although I don't know 2.7 so it may not go too well). 如果没有,我想我可能最终会因为使用R-Pi安装了两个版本而最终选择了Python 2.7(尽管我不知道2.7,所以它可能运行得不太好)。

There are several ways to do this: 做这件事有很多种方法:

  1. You can use OpenCV which has support for getting data from a webcam and there are Python wrappers for it; 您可以使用OpenCV ,它支持从网络摄像头获取数据,并且有Python包装器。
  2. gstreamer has python bindings too; gstreamer也有python绑定;

Also, on GNU/Linux, you can use v4l2 . 另外,在GNU / Linux上,您可以使用v4l2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM