# HG changeset patch # User Nicolas Saunier # Date 1314916418 14400 # Node ID 0f552c8b16504898a53f79052788c53ba2c5006b # Parent ad21db62b78584d6ac88abd7018439bac7f043e9 added python function to play video diff -r ad21db62b785 -r 0f552c8b1650 python/cvutils.py --- a/python/cvutils.py Thu Sep 01 16:44:23 2011 -0400 +++ b/python/cvutils.py Thu Sep 01 18:33:38 2011 -0400 @@ -3,7 +3,7 @@ import Image, ImageDraw # PIL try: - import cv + import cv,cv2 opencvExists = True except ImportError: print('OpenCV library could not be loaded') @@ -57,6 +57,17 @@ cvmat[i,j] = a[i,j] return cvmat + def playVideo(filename): + capture = cv2.VideoCapture(filename) + if capture.isOpened(): + key = -1 + while key!= 1048689: # 'q' + ret, img = capture.read() + if ret: + cv2.imshow('frame', img) + key = cv2.waitKey(5) + + def printCvMat(cvmat, out = stdout): '''Prints the cvmat to out''' for i in xrange(cvmat.rows):