Mercurial > hg > nsaunier > traffic-intelligence
comparison python/cvutils.py @ 958:747a5c68bd3c
minor improvement and bug correction
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 18 Aug 2017 18:00:11 -0400 |
| parents | c03d2c0a4c04 |
| children | 4f32d82ca390 |
comparison
equal
deleted
inserted
replaced
| 957:5d9899504977 | 958:747a5c68bd3c |
|---|---|
| 158 images = [] | 158 images = [] |
| 159 for cap in captures: | 159 for cap in captures: |
| 160 ret, img = cap.read() | 160 ret, img = cap.read() |
| 161 rets.append(ret) | 161 rets.append(ret) |
| 162 images.append(img) | 162 images.append(img) |
| 163 if array(rets).all(): | 163 ret = array(rets).all() |
| 164 if ret: | |
| 164 if printFrames: | 165 if printFrames: |
| 165 print('frame shown {0}'.format(nFramesShown)) | 166 print('frame shown {0}'.format(nFramesShown)) |
| 166 for i in xrange(len(filenames)): | 167 for i in xrange(len(filenames)): |
| 167 if text is not None: | 168 if text is not None: |
| 168 cv2.putText(images[i], text, (10,50), cv2.FONT_HERSHEY_PLAIN, 1, cvRed[colorType]) | 169 cv2.putText(images[i], text, (10,50), cv2.FONT_HERSHEY_PLAIN, 1, cvRed[colorType]) |
| 171 if saveKey(key): | 172 if saveKey(key): |
| 172 cv2.imwrite('image-{}.png'.format(frameNum), img) | 173 cv2.imwrite('image-{}.png'.format(frameNum), img) |
| 173 nFramesShown += step | 174 nFramesShown += step |
| 174 if step > 1: | 175 if step > 1: |
| 175 for i in xrange(len(captures)): | 176 for i in xrange(len(captures)): |
| 176 captures.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, firstFrameNums[i]+nFramesShown) | 177 captures[i].set(cv2.cv.CV_CAP_PROP_POS_FRAMES, firstFrameNums[i]+nFramesShown) |
| 177 cv2.destroyAllWindows() | 178 cv2.destroyAllWindows() |
| 178 else: | 179 else: |
| 179 print('Video captures for {} failed'.format(filenames)) | 180 print('Video captures for {} failed'.format(filenames)) |
| 180 | 181 |
| 181 def infoVideo(filename): | 182 def infoVideo(filename): |
