程序需要读取视频,计算帧数,然后在窗口中显示。错误发生在视频结束后。
我该怎么解决?
来源如下:import tkMessageBox
import cv2
banner = cv2.imread('../data/banner.png')
video = cv2.VideoCapture('../data/pintado_real_crop.avi')
contadorDeFrames = True
contador = 0
cv2.imshow('Projeto Pacu', banner)
cv2.moveWindow('Projeto Pacu', 100,50)
while(contadorDeFrames == True):
contadorDeFrames, frame = video.read()
contador = contador + 1
cv2.imshow("Video", frame)
cv2.moveWindow('Video', 100, 178)
print"Frame: %d" %contador
k = cv2.waitKey(30) & 0xff
if k == 27:
break
tkMessageBox.showinfo("Frames contador: %d" %contador)
video.release()
cv2.destroyAllWindows()
完全错误:OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /build/buildd/opencv-2.4.8+dfsg1/modules/highgui/src/window.cpp, line 269
Traceback (most recent call last):
File "/home/vagner/PycharmProjects/TesteVideo/src/TestaVideo.py", line 20, in
cv2.imshow("Video", frame)
cv2.error: /build/buildd/opencv-2.4.8+dfsg1/modules/highgui/src/window.cpp:269: error: (-215) size.width>0 && size.height>0 in function imshow