changeset 149:0f552c8b1650

added python function to play video
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 01 Sep 2011 18:33:38 -0400
parents ad21db62b785
children 404f3cade05f
files python/cvutils.py
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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):