python 视频清晰度_在opencvpython中调整视频分辨率

我想把我从我的网络摄像头得到的视频分辨率降低到一半(即从640x480到320x240),但我遇到了错误。在import numpy as np

import cv2

cap = cv2.VideoCapture(0)

cap.set(3,320)

cap.set(4,240)

while(True):

# 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)

if cv2.waitKey(1) & 0xFF == ord('q'):

break

# When everything done, release the capture

cap.release()

cv2.destroyAllWindows()

我得到的错误是Traceback (most recent call last): File

"C:\Users\Nemi\Desktop\bbb.py", line 17, in

cv2.imshow('frame',frame) error: ......\opencv-2.4.13.2\modules\highgui\src\window.cpp:269: error:

(-215) size.width>0 && size.height>0 in function cv::imshow

我是新手,找不到解决办法。有人能告诉我我做错了什么吗?在

你可能感兴趣的:(python,视频清晰度)