如何在python2中从网络摄像头捕捉图像?
问题描述:
,我使用的代码给出了输出,但图像随机裁剪和不适合TOT的窗口的大小。当我使用namedWindow("Image", WINDOW_NORMAL);
它给出了错误的 :NameError: name 'CV_WINDOW_AUTOSIZE'
没有定义如何在python2中从网络摄像头捕捉图像?
代码:
from cv2 import *
# initialize the camera
cam = VideoCapture(0) # 0 -> index of camera
s, img = cam.read()
if s: # frame captured without any errors
namedWindow("Image", WINDOW_NORMAL);
imshow("cam-test",img)
waitKey(500)
destroyWindow("cam-test")
imwrite("filename.jpg",img) #save image
我应该怎么办? enter image description here
答
尝试改变:
namedWindow("Image", WINDOW_NORMAL);
到:
namedWindow("Image");