Mercurial Hosting > traffic-intelligence
comparison python/cvutils.py @ 248:571ba5ed22e2
added utils for bus processing
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 18 Jul 2012 02:54:22 -0400 |
parents | e0988a8ace0c |
children | aba9711b3149 |
comparison
equal
deleted
inserted
replaced
247:8f0ed138d373 | 248:571ba5ed22e2 |
---|---|
127 cv2.imwrite('image{0:04d}.png'.format(numImg), img) | 127 cv2.imwrite('image{0:04d}.png'.format(numImg), img) |
128 else: | 128 else: |
129 images.append(img) | 129 images.append(img) |
130 return images | 130 return images |
131 | 131 |
132 def displayTrajectories(videoFilename, objects, homography = None, firstFrameNum = 0): | 132 def displayTrajectories(videoFilename, objects, homography = None, firstFrameNum = 0, lastFrameNumArg = None): |
133 '''Displays the objects overlaid frame by frame over the video ''' | 133 '''Displays the objects overlaid frame by frame over the video ''' |
134 capture = cv2.VideoCapture(videoFilename) | 134 capture = cv2.VideoCapture(videoFilename) |
135 if capture.isOpened(): | 135 if capture.isOpened(): |
136 key = -1 | 136 key = -1 |
137 ret = True | 137 ret = True |
138 frameNum = firstFrameNum | 138 frameNum = firstFrameNum |
139 capture.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, firstFrameNum) | 139 capture.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, firstFrameNum) |
140 while ret and key!= 113: # 'q' | 140 if not lastFrameNumArg: |
141 from sys import maxint | |
142 lastFrameNum = maxint | |
143 else: | |
144 lastFrameNum = lastFrameNumArg | |
145 while ret and key!= 113 and frameNum < lastFrameNum: # 'q' | |
141 ret, img = capture.read() | 146 ret, img = capture.read() |
142 if ret: | 147 if ret: |
143 print('frame {0}'.format(frameNum)) | 148 print('frame {0}'.format(frameNum)) |
144 for obj in objects: | 149 for obj in objects: |
145 if obj.existsAtInstant(frameNum): | 150 if obj.existsAtInstant(frameNum): |