我使用的代码给出了输出但是图像是随机裁剪的,并且不适合窗口的大小。当我使用namedWindow("Image", WINDOW_NORMAL);
时,它会给出错误
:NameError: name 'CV_WINDOW_AUTOSIZE'
未定义
代码:
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
答案 0 :(得分:0)
尝试更改:
namedWindow("Image", WINDOW_NORMAL);
为:
namedWindow("Image");