Mercurial Hosting > traffic-intelligence
comparison python/cvutils.py @ 625:9202628a4130
saving image when playing video
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 13 Feb 2015 09:10:29 -0500 |
parents | b5525249eda1 |
children | 977407c9f815 |
comparison
equal
deleted
inserted
replaced
624:bac66bd536c5 | 625:9202628a4130 |
---|---|
142 frameNum+=1 | 142 frameNum+=1 |
143 if text != None: | 143 if text != None: |
144 cv2.putText(img, text, (10,50), cv2.cv.CV_FONT_HERSHEY_PLAIN, 1, cvRed) | 144 cv2.putText(img, text, (10,50), cv2.cv.CV_FONT_HERSHEY_PLAIN, 1, cvRed) |
145 cvImshow(windowName, img, rescale) | 145 cvImshow(windowName, img, rescale) |
146 key = cv2.waitKey(wait) | 146 key = cv2.waitKey(wait) |
147 if saveKey(key): | |
148 cv2.imwrite('image-{}.png'.format(frameNum), img) | |
147 cv2.destroyAllWindows() | 149 cv2.destroyAllWindows() |
148 else: | 150 else: |
149 print('Video capture for {} failed'.format(filename)) | 151 print('Video capture for {} failed'.format(filename)) |
150 | 152 |
151 def getImagesFromVideo(videoFilename, firstFrameNum = 0, nFrames = 1, saveImage = False, outputPrefix = 'image'): | 153 def getImagesFromVideo(videoFilename, firstFrameNum = 0, nFrames = 1, saveImage = False, outputPrefix = 'image'): |