Queryframe Not Advancing Frame In Opencv
The code import cv capture = cv.CaptureFromFile('a.avi') while True: frame = cv.QueryFrame(capture) cv.ShowImage('a',frame) Shows the same initial frame from the video
Solution 1:
I see the same mistakes over and over again, so this is probably the last time I'll address them. Hopefully people will start using the search box in the future and dig a little deeper.
Call cv.WaitKey()
after displaying the frame. If don't have a delay between displaying the frames some problems could happen. I believe this the problem.
Code defensively: if you are calling a function/method that can fail, believe in Murphy, and add the appropriate check to verify it doesn't:
import cv
capture = cv.CaptureFromFile("a.avi")
if not capture :
print"Error loading video file"# Should exit the applicationwhileTrue:
frame = cv.QueryFrame(capture)
if not frame:
print"Could not retrieve frame"
cv.ShowImage("a", frame)
k = cv.WaitKey(10)
if k == 27:
break# ESC key was pressed
Post a Comment for "Queryframe Not Advancing Frame In Opencv"