【发布时间】:2016-04-30 13:49:12
【问题描述】:
我正在尝试启动网络摄像头并使用 python 捕获图像我使用了以下代码
import cv as cv2
cv2.namedWindow("preview")
vc = cv2.VideoCapture(0)
if vc.isOpened(): # try to get the first frame
rval, frame = vc.read()
else:
rval = False
while rval:
cv2.imshow("preview", frame)
rval, frame = vc.read()
key = cv2.waitKey(20)
if key == 27: # exit on ESC
break
cv2.VideoCapture.open(0)
cv2.destroyWindow("preview")
这会启动相机并在按下 Esc 时关闭但不捕获图像。我是否缺少捕获图像的命令?
【问题讨论】:
-
是否要捕获图像并将其保存到文件中?
-
当然是在捕捉。
-
您的 python 脚本有小的缩进错误。修复它。
标签: python camera image-capture