python - 无法打开相机 - OpenCV MacOS Python3
问题描述
规格详情
- MacBook Pro 2020 13"
- MacOS 版本:Bigsur 11.3.1
- OpenCV 版本:4.5.1
- Python版本:3.9.4
- 摄像头:默认 Facetime 摄像头
- 在 iTerm 2 Build 3.4.6 上运行
问题
启动此代码时未打开相机:
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
while cap.isOpened():
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Display the resulting frame
cv2.imshow('frame',frame)
cv2.imshow('gray',gray)
if cv2.waitKey(20) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
截屏
附加信息 :
我安装了两个摄像头(其中一个是 epoccam,一个将智能手机用作摄像头的摄像头驱动器)
解决方案
通过卸载 EpocCam 解决
推荐阅读
- java - 无法完全模拟 RestHighLevelClient
- json - 如何在 Grafana 中进行 Simple-JSON 变量模板查询?
- java - 当一个表与休眠中的另一个表链接时更新一个表中的列
- whatsapp - 仅使用 HREF 通过 whatsapp 发送文件 (.PDF)
- excel - 比较两列/行以获得完全匹配并突出显示差异
- rxjs - RxJS / Redux-observables:我将如何测试 EventEmitter?
- apache-camel - 在 Camel XSLT 处理中可能导致 NullPointerException 的原因是什么?
- python - 字符串到日期字段的转换
- python - 将 Numpy 结构化数组转换为结构的 C 数组
- python-3.x - 使用 boto3 扫描 Dynamo DB 以获取字典数组