Is there a way to get a specific frame using VideoCapture()
method?
My current code is:
import numpy as np
import cv2
cap = cv2.VideoCaptur
If you want an exact frame, you could just set the VideoCapture session to that frame. It's much more intuitive to automatically call on that frame. The "correct" solution requires you to input known data: like fps, length, and whatnot. All you need to know with the code below is the frame you want to call.
import numpy as np
import cv2
cap = cv2.VideoCapture(video_name) #video_name is the video being called
cap.set(1,frame_no); # Where frame_no is the frame you want
ret, frame = cap.read() # Read the frame
cv2.imshow('window_name', frame) # show frame on window
If you want to hold the window, until you press exit:
while True:
ch = 0xFF & cv2.waitKey(1) # Wait for a second
if ch == 27:
break