Mercurial Hosting > traffic-intelligence
comparison python/cvutils.py @ 799:0662c87a61c9 dev
minor modification
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 30 May 2016 23:01:53 -0400 |
parents | 5b99b676265e |
children | 52aa03260f03 |
comparison
equal
deleted
inserted
replaced
798:5b99b676265e | 799:0662c87a61c9 |
---|---|
228 rawCount = lastFrameNum+1 | 228 rawCount = lastFrameNum+1 |
229 nDigits = int(floor(log10(rawCount)))+1 | 229 nDigits = int(floor(log10(rawCount)))+1 |
230 ret = False | 230 ret = False |
231 capture.set(cv2.CAP_PROP_POS_FRAMES, firstFrameNum) | 231 capture.set(cv2.CAP_PROP_POS_FRAMES, firstFrameNum) |
232 frameNum = firstFrameNum | 232 frameNum = firstFrameNum |
233 while frameNum<=lastFrameNum: | 233 while frameNum<=lastFrameNum and frameNum<rawCount: |
234 ret, img = capture.read() | 234 ret, img = capture.read() |
235 i = 0 | 235 i = 0 |
236 while not ret and i<10: | 236 while not ret and i<10: |
237 ret, img = capture.read() | 237 ret, img = capture.read() |
238 i += 1 | 238 i += 1 |
239 if img.size>0: | 239 if img is not None and img.size>0: |
240 if saveImage: | 240 if saveImage: |
241 frameNumStr = format(frameNum, '0{}d'.format(nDigits)) | 241 frameNumStr = format(frameNum, '0{}d'.format(nDigits)) |
242 cv2.imwrite(outputPrefix+frameNumStr+'.png', img) | 242 cv2.imwrite(outputPrefix+frameNumStr+'.png', img) |
243 else: | 243 else: |
244 images.append(img) | 244 images.append(img) |