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
Yes, it's very straight forward:
import cv2
cap = cv2.VideoCapture(videopath)
cap.set(cv2.CV_CAP_PROP_POS_FRAMES, frame_number-1)
res, frame = cap.read()
'frame_number' is an integer in range 0...amount_of_frames. Notice: you should set 'frame_number-1' to force reading frame 'frame_number'. It's not documented well but test shows that behavior of VideoCapture module.
'res' is boolean result of operation, one may use it to check if frame was successfully read. One may obtain amount of frames by:
amount_of_frames = cap.get(cv2.CV_CAP_PROP_FRAME_COUNT)