Mercurial Hosting > traffic-intelligence
comparison trafficintelligence/moving.py @ 1249:2aa56b101041
added mask functionality for dltrack
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 15 Feb 2024 14:09:52 -0500 |
parents | 371c718e57d7 |
children | 77fbd0e2ba7d |
comparison
equal
deleted
inserted
replaced
1248:c4c50678c856 | 1249:2aa56b101041 |
---|---|
1 #! /usr/bin/env python | 1 #! /usr/bin/env python |
2 '''Libraries for moving objects, trajectories...''' | 2 '''Libraries for moving objects, trajectories...''' |
3 | 3 |
4 import copy | 4 import copy |
5 from math import sqrt, atan2, cos, sin | 5 from math import sqrt, atan2, cos, sin, inf |
6 | 6 |
7 from numpy import median, mean, array, arange, zeros, ones, hypot, NaN, std, floor, ceil, float32, argwhere, minimum, issubdtype, integer as npinteger, percentile | 7 from numpy import median, mean, array, arange, zeros, ones, hypot, NaN, std, floor, ceil, float32, argwhere, minimum, issubdtype, integer as npinteger, percentile |
8 from matplotlib.pyplot import plot, text, arrow | 8 from matplotlib.pyplot import plot, text, arrow |
9 from scipy.spatial.distance import cdist | 9 from scipy.spatial.distance import cdist |
10 from scipy.signal import savgol_filter | 10 from scipy.signal import savgol_filter |
293 | 293 |
294 def astuple(self): | 294 def astuple(self): |
295 return (self.x, self.y) | 295 return (self.x, self.y) |
296 | 296 |
297 def asint(self): | 297 def asint(self): |
298 return Point(int(self.x), int(self.y)) | 298 return Point(int(round(self.x)), int(round(self.y))) |
299 | 299 |
300 if shapelyAvailable: | 300 if shapelyAvailable: |
301 def asShapely(self): | 301 def asShapely(self): |
302 return shapelyPoint(self.x, self.y) | 302 return shapelyPoint(self.x, self.y) |
303 | 303 |
2052 for userTypename in speedProbabilities: | 2052 for userTypename in speedProbabilities: |
2053 userTypeProbabilities[userType2Num[userTypename]] = speedProbabilities[userTypename](self.aggregatedSpeed) | 2053 userTypeProbabilities[userType2Num[userTypename]] = speedProbabilities[userTypename](self.aggregatedSpeed) |
2054 self.setUserType(utils.argmaxDict(userTypeProbabilities)) | 2054 self.setUserType(utils.argmaxDict(userTypeProbabilities)) |
2055 return userTypeProbabilities | 2055 return userTypeProbabilities |
2056 | 2056 |
2057 def initClassifyUserTypeHoGSVM(self, aggregationFunc, pedBikeCarSVM, bikeCarSVM = None, pedBikeSpeedThreshold = float('Inf'), bikeCarSpeedThreshold = float('Inf'), nInstantsIgnoredAtEnds = 0, homography = None, intrinsicCameraMatrix = None, distortionCoefficients = None): | 2057 def initClassifyUserTypeHoGSVM(self, aggregationFunc, pedBikeCarSVM, bikeCarSVM = None, pedBikeSpeedThreshold = inf, bikeCarSpeedThreshold = float('Inf'), nInstantsIgnoredAtEnds = 0, homography = None, intrinsicCameraMatrix = None, distortionCoefficients = None): |
2058 '''Initializes the data structures for classification | 2058 '''Initializes the data structures for classification |
2059 | 2059 |
2060 TODO? compute speed for longest feature?''' | 2060 TODO? compute speed for longest feature?''' |
2061 self.aggregatedSpeed = aggregationFunc(self.getSpeeds(nInstantsIgnoredAtEnds)) | 2061 self.aggregatedSpeed = aggregationFunc(self.getSpeeds(nInstantsIgnoredAtEnds)) |
2062 if self.aggregatedSpeed < pedBikeSpeedThreshold or bikeCarSVM is None: | 2062 if self.aggregatedSpeed < pedBikeSpeedThreshold or bikeCarSVM is None: |