comparison python/cvutils.py @ 549:b5525249eda1

Merged in mohamedgomaa/trafficintelligence (pull request #7) add some functions for behaviour analysis and corrected a few bugs
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 08 Jul 2014 16:32:09 -0400
parents 9816fab353f3 e6ab4caf359c
children 9202628a4130
comparison
equal deleted inserted replaced
545:9816fab353f3 549:b5525249eda1
208 xCropMax = int(min(width - 1, .5 * (xmin + xmax + a))) 208 xCropMax = int(min(width - 1, .5 * (xmin + xmax + a)))
209 if yCropMax != yCropMin and xCropMax != xCropMin and (yCropMax - yCropMin) * (xCropMax - xCropMin) > pixelThreshold: 209 if yCropMax != yCropMin and xCropMax != xCropMin and (yCropMax - yCropMin) * (xCropMax - xCropMin) > pixelThreshold:
210 croppedImg = img[yCropMin : yCropMax, xCropMin : xCropMax] 210 croppedImg = img[yCropMin : yCropMax, xCropMin : xCropMax]
211 else: 211 else:
212 croppedImg = [] 212 croppedImg = []
213 return imgcrop, yCropMin, yCropMax, xCropMin, xCropMax 213 return croppedImg, yCropMin, yCropMax, xCropMin, xCropMax
214 214
215 215
216 def displayTrajectories(videoFilename, objects, boundingBoxes = {}, homography = None, firstFrameNum = 0, lastFrameNumArg = None, printFrames = True, rescale = 1., nFramesStep = 1, saveAllImages = False, undistort = False, intrinsicCameraMatrix = None, distortionCoefficients = None, undistortedImageMultiplication = 1.): 216 def displayTrajectories(videoFilename, objects, boundingBoxes = {}, homography = None, firstFrameNum = 0, lastFrameNumArg = None, printFrames = True, rescale = 1., nFramesStep = 1, saveAllImages = False, undistort = False, intrinsicCameraMatrix = None, distortionCoefficients = None, undistortedImageMultiplication = 1.):
217 '''Displays the objects overlaid frame by frame over the video ''' 217 '''Displays the objects overlaid frame by frame over the video '''
218 from moving import userTypeNames 218 from moving import userTypeNames
423 if (homography!=None) and homography.size>0: 423 if (homography!=None) and homography.size>0:
424 augmentedPoints = append(points,[[1]*points.shape[1]], 0) 424 augmentedPoints = append(points,[[1]*points.shape[1]], 0)
425 prod = dot(homography, augmentedPoints) 425 prod = dot(homography, augmentedPoints)
426 return prod[0:2]/prod[2] 426 return prod[0:2]/prod[2]
427 else: 427 else:
428 return p 428 return points
429 429
430 def project(homography, p): 430 def project(homography, p):
431 '''Returns the coordinates of the projection of the point p with coordinates p[0], p[1] 431 '''Returns the coordinates of the projection of the point p with coordinates p[0], p[1]
432 through homography''' 432 through homography'''
433 from numpy import array 433 from numpy import array