它仍然会出错。当我写下面的代码时:
如果我写:cap = cv2.VideoCapture(0)
,我的代码可以正常工作。但每当我写cap = cv2.VideoCapture('C:\Users\Anjali\Documents\Python_Files\Video_tracking\slow.mp4')
时,它都不起作用。
以下是我的代码:
import cv2
import numpy as np
cap = cv2.VideoCapture('C:\Users\Anjali\Documents\Python_Files\Video_tracking\slow.mp4')
while (True):
ret, frame = cap.read()
#gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('Frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
它出现以下错误,请帮助我:
cv2.imshow('Frame', frame)
error: ..\..\..\..\opencv\modules\highgui\src\window.cpp:261: error: (-215) size.width>0 && size.height>0 in function cv::imshow