简体   繁体   English

如何在Python中使用网络摄像头捕获图像?

[英]How do I capture images using webcam in Python?

There are certain libraries such as fswebcam, cv2 etc. But pip cant find a matching distribution for Python3 on Win7 64bit. 有某些库,例如fswebcam,cv2等。但是pip在Win7 64位上找不到Python3的匹配发行版。 Are there any other libraries or how can i use these two to capture images from Python 是否还有其他库或我如何使用这两个库从Python捕获图像

I installed openCV on my 64-bit windows 10 machine using openCV and numpy wheels, which I installed using pip. 我使用openCV和numpy滚轮在我的64位Windows 10机器上安装了openCV,我使用pip进行了安装。

You can find the numpy wheels here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy 您可以在此处找到numpy轮子: https : //www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

And the cv2 wheels here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv 和cv2轮子在这里: https ://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv

Make sure you find the wheels specific to your setup, ie. 确保找到适合您的设置的轮子,即。 64-bit with python 3.6, use: numpy‑1.14.5+mkl‑cp36‑cp36m‑win_amd64.whl 使用python 3.6的64位,请使用:numpy‑1.14.5 + mkl‑cp36‑cp36m‑win_amd64.whl

Save those in a folder, then navigate to that folder in a command window and install the files using pip. 将其保存在文件夹中,然后在命令窗口中导航到该文件夹​​,然后使用pip安装文件。

The full guide is here if needed: https://solarianprogrammer.com/2016/09/17/install-opencv-3-with-python-3-on-windows/ 如果需要的话,完整的指南在这里: https : //solarianprogrammer.com/2016/09/17/install-opencv-3-with-python-3-on-windows/

I guess the reason is that you have both Python2 and Python3 installed, and therefore pip only works for Python 2. You can install OpenCV as follows: 我想原因是您同时安装了Python2和Python3,因此pip仅适用于Python2。您可以按以下方式安装OpenCV:

python3 -m pip install opencv-python

You have to make sure Python 3 has been added to the system path and the command Python3 is available. 您必须确保已将Python 3添加到系统路径中,并且命令Python3可用。 If the executable file of Python 3 is named Python , just rename it to Python3 . 如果Python 3的可执行文件名为Python ,只需将其重命名为Python3

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

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