# HG changeset patch # User Nicolas Saunier # Date 1314916655 14400 # Node ID 404f3cade05fcefe073de2b31ffc9b187959b510 # Parent 0f552c8b16504898a53f79052788c53ba2c5006b added python function to get image frames from video filenames diff -r 0f552c8b1650 -r 404f3cade05f python/cvutils.py --- a/python/cvutils.py Thu Sep 01 18:33:38 2011 -0400 +++ b/python/cvutils.py Thu Sep 01 18:37:35 2011 -0400 @@ -58,6 +58,7 @@ return cvmat def playVideo(filename): + '''Plays the video''' capture = cv2.VideoCapture(filename) if capture.isOpened(): key = -1 @@ -67,6 +68,18 @@ cv2.imshow('frame', img) key = cv2.waitKey(5) + def getImagesFromVideo(filename, nImages = 1): + '''Returns nImages images from the video sequence''' + images = [] + capture = cv2.VideoCapture(filename) + if capture.isOpened(): + ret = False + while len(images)0: + images.append(img) + return images def printCvMat(cvmat, out = stdout): '''Prints the cvmat to out'''