Created
October 28, 2015 22:07
-
-
Save alexanderkoumis/10bd5a48caa143108ded to your computer and use it in GitHub Desktop.
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 sys | |
def run(video_path): | |
cap = cv2.VideoCapture(video_path) | |
if not cap.isOpened(): | |
print video_path, 'doesn\'t exist' | |
sys.exit() | |
frame_num_curr = int(cap.get(cv2.cv.CV_CAP_PROP_POS_FRAMES)) | |
frame_num_total = int(cap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT)) | |
while True: | |
flag, frame_bgr = cap.read() | |
if flag: | |
frame_num_curr = int(cap.get(cv2.cv.CV_CAP_PROP_POS_FRAMES)) | |
process(frame_bgr, frame_num_curr, frame_num_total) | |
if frame_num_curr == frame_num_total: | |
break | |
else: | |
print 'Error reading frame' | |
print 'Read all images' | |
def process(frame, frame_num_curr, frame_num_total): | |
cv2.imshow('lol', frame) | |
cv2.waitKey(33) | |
if __name__ == '__main__': | |
run(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment