Mercurial Hosting > traffic-intelligence
comparison python/cvutils.py @ 171:8e7b354666ec
corrected bug in to get images from video
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 17 Oct 2011 14:16:50 -0400 |
parents | b0719b3ad3db |
children | e2f31813ade6 |
comparison
equal
deleted
inserted
replaced
170:e99f6c44a655 | 171:8e7b354666ec |
---|---|
101 images = [] | 101 images = [] |
102 capture = cv2.VideoCapture(filename) | 102 capture = cv2.VideoCapture(filename) |
103 if capture.isOpened(): | 103 if capture.isOpened(): |
104 ret = False | 104 ret = False |
105 while len(images)<nImages: | 105 while len(images)<nImages: |
106 ret, img = capture.read() | |
106 while not ret: | 107 while not ret: |
107 ret, img = capture.read() | 108 ret, img = capture.read() |
108 if img.size>0: | 109 if img.size>0: |
109 images.append(img) | 110 images.append(img) |
110 return images | 111 return images |
111 | 112 |
112 def printCvMat(cvmat, out = stdout): | 113 def printCvMat(cvmat, out = stdout): |
113 '''Prints the cvmat to out''' | 114 '''Prints the cvmat to out''' |
114 for i in xrange(cvmat.rows): | 115 for i in xrange(cvmat.rows): |