Ale*_*ger 4 python macos isight opencv
几天后,我无法再从opencv应用程序中打开我的iSight摄像头了.cap = cv2.VideoCapture(0)返回并cap.isOpened()返回true.但是,cap.grab()只需返回false.有任何想法吗?
示例代码:
import cv2
cv2.namedWindow("preview")
vc = cv2.VideoCapture(0)
rval = True
while rval:
rval, frame = vc.read()
cv2.imshow("preview", frame)
key = cv2.waitKey(20)
if key == 27: # exit on ESC
break
Run Code Online (Sandbox Code Playgroud)
小智 9
这就是我让相机为您的代码工作的方式(在OSX 10.6上):
import cv2
cv2.namedWindow("preview")
vc = cv2.VideoCapture(0)
rval, frame = vc.read()
while True:
if frame is not None:
cv2.imshow("preview", frame)
rval, frame = vc.read()
if cv2.waitKey(1) & 0xFF == ord('q'):
break
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8281 次 |
| 最近记录: |