Last active
January 31, 2018 04:09
-
-
Save garybradski/7a8432083ccdbcb4ef3db31c22344da4 to your computer and use it in GitHub Desktop.
AVI2PGM.py
This file contains hidden or 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
| import cv2 | |
| import argparse | |
| import os | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('--video', help='path to video to convert to images.') | |
| parser.add_argument('--out', help='path to output directory.') | |
| args = parser.parse_args() | |
| if not os.path.exists(args.out): | |
| os.makedirs(args.out) | |
| cap = cv2.VideoCapture(args.video) | |
| ctr = 0 | |
| while True: | |
| print(ctr) | |
| ret, frame = cap.read() | |
| print(frame.size) | |
| if not frame.size: | |
| break | |
| #cv2.imshow('frame', frame) | |
| #cv2.waitKey(10) | |
| image_name = 'fg_%09d.png' % ctr | |
| cv2.imwrite(args.out + '/' + image_name, frame) | |
| ctr += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment