Python:无需OpenCV即可访问摄像头 [英] Python: Access camera WITHOUT OpenCV
问题描述
同志
我想用Python从笔记本电脑摄像头捕获图像.目前,所有迹象都指向OpenCV.问题是OpenCV是要安装的噩梦,并且是每次在新系统上重新安装代码时都会发生的噩梦.
I'd like to capture images from the laptop camera in Python. Currently all signs point to OpenCV. Problem is OpenCV is a nightmare to install, and it's a nightmare that reoccurs every time you reinstall your code on a new system.
是否有更轻巧的方法来捕获Python中的相机数据?我正在寻找能起到以下作用的东西:
Is there a more lightweight way to capture camera data in Python? I'm looking for something to the effect of:
$ pip install something
$ python
>>> import something
>>> im = something.get_camera_image()
我在Mac上,但欢迎在任何平台上使用解决方案.
I'm on Mac, but solutions on any platform are welcome.
推荐答案
作为该文档状态,目前pygame.camera
仅支持linux和v4l2摄像机,因此这不适用于macOS.相反,在Linux上,它可以正常工作.
As the documentation states, currently pygame.camera
only supports linux and v4l2 cameras, so this would not work on macOS. On Linux instead it works fine.
这篇关于Python:无需OpenCV即可访问摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!