Mercurial Hosting > traffic-intelligence
comparison trafficintelligence/cvutils.py @ 1158:7eb972942f22
solving bug to pass kwargs for plotting
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 05 Jan 2021 10:45:39 -0500 |
parents | b358bed29ab4 |
children | d71a4d174b1a |
comparison
equal
deleted
inserted
replaced
1157:173b7926734e | 1158:7eb972942f22 |
---|---|
310 if dryRun: | 310 if dryRun: |
311 print(cmd) | 311 print(cmd) |
312 else: | 312 else: |
313 run(cmd) | 313 run(cmd) |
314 | 314 |
315 def displayTrajectories(videoFilename, objects, boundingBoxes = {}, homography = None, firstFrameNum = 0, lastFrameNumArg = None, printFrames = True, rescale = 1., nFramesStep = 1, saveAllImages = False, nZerosFilenameArg = None, undistort = False, intrinsicCameraMatrix = None, distortionCoefficients = None, undistortedImageMultiplication = 1., annotations = [], gtMatches = {}, toMatches = {}, colorBlind = False): | 315 def displayTrajectories(videoFilename, objects, boundingBoxes = {}, homography = None, firstFrameNum = 0, lastFrameNumArg = None, printFrames = True, rescale = 1., nFramesStep = 1, saveAllImages = False, nZerosFilenameArg = None, undistort = False, intrinsicCameraMatrix = None, distortionCoefficients = None, undistortedImageMultiplication = 1., annotations = [], gtMatches = {}, toMatches = {}, colorBlind = False, **kwargs): |
316 '''Displays the objects overlaid frame by frame over the video ''' | 316 '''Displays the objects overlaid frame by frame over the video ''' |
317 if colorBlind: | 317 if colorBlind: |
318 colorType = 'colorblind' | 318 colorType = 'colorblind' |
319 else: | 319 else: |
320 colorType = 'default' | 320 colorType = 'default' |
357 if obj.existsAtInstant(frameNum): | 357 if obj.existsAtInstant(frameNum): |
358 if not hasattr(obj, 'projectedPositions'): | 358 if not hasattr(obj, 'projectedPositions'): |
359 obj.projectedPositions = obj.getPositions().homographyProject(homography) | 359 obj.projectedPositions = obj.getPositions().homographyProject(homography) |
360 if undistort: | 360 if undistort: |
361 obj.projectedPositions = obj.projectedPositions.newCameraProject(newCameraMatrix) | 361 obj.projectedPositions = obj.projectedPositions.newCameraProject(newCameraMatrix) |
362 cvPlot(img, obj.projectedPositions, cvColors[colorType][obj.getNum()], frameNum-obj.getFirstInstant()) | 362 cvPlot(img, obj.projectedPositions, cvColors[colorType][obj.getNum()], frameNum-obj.getFirstInstant(), **kwargs) |
363 if frameNum not in boundingBoxes and obj.hasFeatures(): | 363 if frameNum not in boundingBoxes and obj.hasFeatures(): |
364 yCropMin, yCropMax, xCropMin, xCropMax = imageBoxSize(obj, frameNum, homography, width, height) | 364 yCropMin, yCropMax, xCropMin, xCropMax = imageBoxSize(obj, frameNum, homography, width, height) |
365 cv2.rectangle(img, (xCropMin, yCropMin), (xCropMax, yCropMax), cvBlue[colorType], 1) | 365 cv2.rectangle(img, (xCropMin, yCropMin), (xCropMax, yCropMax), cvBlue[colorType], 1) |
366 objDescription = '{} '.format(obj.num) | 366 objDescription = '{} '.format(obj.num) |
367 if moving.userTypeNames[obj.userType] != 'unknown': | 367 if moving.userTypeNames[obj.userType] != 'unknown': |