I am a begginer in OpenCV and Python. I tried to load a video and displaying it using code given below:
import cv2
cap = cv2.VideoCapture('G:\3d scanner\2.mmv')
while(1):
_ , img2=cap.read()
cv2.namedWindow('video',cv2.WINDOW_NORMAL)
cv2.imshow('video',img2)
k=cv2.waitKey(1) & 0xFF
if k==27:
break
cap.release()
cv2.destroyAllWindows()
But it showing the following error:
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow, file ..\..\..\..\opencv\modules\highgui\src\window.cpp, line 261
File "test3.py", line 8, in <module>
cv2.imshow('video',img2)
cv2.error: ..\..\..\..\opencv\modules\highgui\src\window.cpp:261: error: (-215) size.width>0 && size.height>0 in function cv::imshow
There are previous questions on this site regarding this issue but the answers given were using cv library but not cv2.
Any idea of what is wrong in this?