Mercurial Hosting > traffic-intelligence
comparison python/cvutils.py @ 478:d337bffd7283
Display of points in compute homography and step option to replay videos
A bug seems to remain with respect to trajectory bounds, to check
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 27 Mar 2014 11:40:28 -0400 |
parents | 59903d14d244 |
children | f6415f012640 |
comparison
equal
deleted
inserted
replaced
477:ed4166b0ba9d | 478:d337bffd7283 |
---|---|
200 else: | 200 else: |
201 imgcrop = [] | 201 imgcrop = [] |
202 return imgcrop, yCropMin, yCropMax, xCropMin, xCropMax | 202 return imgcrop, yCropMin, yCropMax, xCropMin, xCropMax |
203 | 203 |
204 | 204 |
205 def displayTrajectories(videoFilename, objects, boundingBoxes = {}, homography = None, firstFrameNum = 0, lastFrameNumArg = None, printFrames = True, rescale = 1.): | 205 def displayTrajectories(videoFilename, objects, boundingBoxes = {}, homography = None, firstFrameNum = 0, lastFrameNumArg = None, printFrames = True, rescale = 1., nFramesStep = 1): |
206 '''Displays the objects overlaid frame by frame over the video ''' | 206 '''Displays the objects overlaid frame by frame over the video ''' |
207 from moving import userTypeNames | 207 from moving import userTypeNames |
208 | 208 |
209 capture = cv2.VideoCapture(videoFilename) | 209 capture = cv2.VideoCapture(videoFilename) |
210 width = int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)) | 210 width = int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)) |
244 cv2.putText(img, objDescription, obj.projectedPositions[frameNum-obj.getFirstInstant()].asint().astuple(), cv2.cv.CV_FONT_HERSHEY_PLAIN, 1, cvRed) | 244 cv2.putText(img, objDescription, obj.projectedPositions[frameNum-obj.getFirstInstant()].asint().astuple(), cv2.cv.CV_FONT_HERSHEY_PLAIN, 1, cvRed) |
245 cvImshow('frame', img, rescale) | 245 cvImshow('frame', img, rescale) |
246 key = cv2.waitKey() | 246 key = cv2.waitKey() |
247 if saveKey(key): | 247 if saveKey(key): |
248 cv2.imwrite('image.png', img) | 248 cv2.imwrite('image.png', img) |
249 frameNum += 1 | 249 frameNum += nFramesStep |
250 if nFramesStep > 1: | |
251 capture.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, frameNum) | |
250 cv2.destroyAllWindows() | 252 cv2.destroyAllWindows() |
251 else: | 253 else: |
252 print 'Cannot load file ' + videoFilename | 254 print 'Cannot load file ' + videoFilename |
253 | 255 |
254 def computeHomographyFromPDTV(cameraFilename, method=0, ransacReprojThreshold=3.0): | 256 def computeHomographyFromPDTV(cameraFilename, method=0, ransacReprojThreshold=3.0): |