Mercurial Hosting > traffic-intelligence
diff trafficintelligence/moving.py @ 1203:7b3384a8e409
second version of code loading kitti data, to clean
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 22 Mar 2023 15:40:33 -0400 |
parents | 0475b4cd0cfb |
children | 3905b393ade0 |
line wrap: on
line diff
--- a/trafficintelligence/moving.py Thu Mar 16 17:03:18 2023 -0400 +++ b/trafficintelligence/moving.py Wed Mar 22 15:40:33 2023 -0400 @@ -357,8 +357,13 @@ return (p1-p2).norm2() @staticmethod - def plotAll(points, options = '', **kwargs): - plot([p.x for p in points], [p.y for p in points], options, **kwargs) + def plotAll(points, options = '', closePolygon = False, **kwargs): + xCoords = [p.x for p in points] + yCoords = [p.y for p in points] + if closePolygon: + xCoords.append[0] + yCoords.append[0] + plot(xCoords, yCoords, options, **kwargs) def similarOrientation(self, refDirection, cosineThreshold): 'Indicates whether the cosine of the vector and refDirection is smaller than cosineThreshold' @@ -1253,7 +1258,7 @@ and a usertype (e.g. road user) coded as a number (see userTypeNames) ''' - def __init__(self, num = None, timeInterval = None, positions = None, velocities = None, geometry = None, userType = userType2Num['unknown'], nObjects = None, initCurvilinear = False): + def __init__(self, num = None, timeInterval = None, positions = None, velocities = None, geometry = None, userType = userType2Num['unknown'], nObjects = None, features = None, initCurvilinear = False): super(MovingObject, self).__init__(num, timeInterval) if initCurvilinear: self.curvilinearPositions = positions @@ -1264,7 +1269,7 @@ self.geometry = geometry self.userType = userType self.setNObjects(nObjects) # a feature has None for nObjects - self.features = None + self.features = features # compute bounding polygon from trajectory @staticmethod @@ -1651,6 +1656,11 @@ else: self.positions.plotOnWorldImage(nPixelsPerUnitDistance, options, withOrigin, timeStep, None, **kwargs) + def plotOutlineAtInstant(self, t, options = '', **kwargs): + if self.hasFeatures(): + points = [f.getPositionAtInstant(t) for f in self.getFeatures()] + Point.plotAll(points, options, True, kwargs) + def play(self, videoFilename, homography = None, undistort = False, intrinsicCameraMatrix = None, distortionCoefficients = None, undistortedImageMultiplication = 1.): cvutils.displayTrajectories(videoFilename, [self], homography = homography, firstFrameNum = self.getFirstInstant(), lastFrameNumArg = self.getLastInstant(), undistort = undistort, intrinsicCameraMatrix = intrinsicCameraMatrix, distortionCoefficients = distortionCoefficients, undistortedImageMultiplication = undistortedImageMultiplication)