Created
December 19, 2019 08:55
-
-
Save vereperrot/dd2263e220e68555d687f2ed2075d590 to your computer and use it in GitHub Desktop.
read specific frame using VideoCapture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://stackoverflow.com/questions/33650974/opencv-python-read-specific-frame-using-videocapture | |
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 |
Thanks for uploading this! It was exactly what I was looking for.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Needed this, thanks