Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import cv2 as cv
- # video taken from here: https://www.youtube.com/watch?v=uUMRB829j-I
- # downloaded with: https://youtube-mp4.download/de/free-converter
- if __name__ == '__main__':
- print('started')
- video_path = 'D:\scenic_drive.mp4'
- cap = cv.VideoCapture(video_path)
- frame_counter = 0
- while (True):
- # get frame
- ret, frame = cap.read()
- # check for valid frame
- if ret:
- # resize and display
- frame = cv.resize(frame, (0, 0), None, .3, .3)
- cv.imshow('Drive', frame)
- # counter logic
- print(frame_counter)
- frame_counter = frame_counter + 1
- else:
- cap.release()
- cv.destroyAllWindows()
- print('finished')
- # key press logic
- wait = True
- while(wait):
- key = (cv.waitKey(1) & 0xFF)
- if key == ord('p'):
- wait = False
- if key == ord('q'):
- cap.release()
- cv.destroyAllWindows()
- print('finished')
Add Comment
Please, Sign In to add comment