comparison trafficintelligence/moving.py @ 1245:371c718e57d7

interface updates
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 08 Feb 2024 16:10:54 -0500
parents 4cd8ace3552f
children 2aa56b101041
comparison
equal deleted inserted replaced
1244:00b71da2baac 1245:371c718e57d7
1398 ################## 1398 ##################
1399 1399
1400 userTypeNames = ['unknown', 1400 userTypeNames = ['unknown',
1401 'car', 1401 'car',
1402 'pedestrian', 1402 'pedestrian',
1403 'motorcycle', 1403 'motorcyclist',
1404 'cyclist', 1404 'cyclist',
1405 'bus', 1405 'bus',
1406 'truck', 1406 'truck',
1407 'automated'] 1407 'automated']
1408 1408
1845 p = self.getPositionAtInstant(t) 1845 p = self.getPositionAtInstant(t)
1846 v = self.getVelocityAtInstant(t)*velocityMultiply 1846 v = self.getVelocityAtInstant(t)*velocityMultiply
1847 arrow(p.x, p.y, v.x, v.y, width=arrowWidth) 1847 arrow(p.x, p.y, v.x, v.y, width=arrowWidth)
1848 1848
1849 def play(self, videoFilename, homography = None, undistort = False, intrinsicCameraMatrix = None, distortionCoefficients = None, undistortedImageMultiplication = 1.): 1849 def play(self, videoFilename, homography = None, undistort = False, intrinsicCameraMatrix = None, distortionCoefficients = None, undistortedImageMultiplication = 1.):
1850 cvutils.displayTrajectories(videoFilename, [self], homography = homography, firstFrameNum = self.getFirstInstant(), lastFrameNumArg = self.getLastInstant(), undistort = undistort, intrinsicCameraMatrix = intrinsicCameraMatrix, distortionCoefficients = distortionCoefficients, undistortedImageMultiplication = undistortedImageMultiplication) 1850 cvutils.displayTrajectories(videoFilename, [self], homography = homography, firstFrameNum = self.getFirstInstant(), lastFrameNum = self.getLastInstant(), undistort = undistort, intrinsicCameraMatrix = intrinsicCameraMatrix, distortionCoefficients = distortionCoefficients, undistortedImageMultiplication = undistortedImageMultiplication)
1851 1851
1852 def speedDiagnostics(self, framerate = 1., display = False, nInstantsIgnoredAtEnds=0): 1852 def speedDiagnostics(self, framerate = 1., display = False, nInstantsIgnoredAtEnds=0):
1853 speeds = framerate*self.getSpeeds(nInstantsIgnoredAtEnds) 1853 speeds = framerate*self.getSpeeds(nInstantsIgnoredAtEnds)
1854 coef = utils.linearRegression(list(range(len(speeds))), speeds) 1854 coef = utils.linearRegression(list(range(len(speeds))), speeds)
1855 print('min/5th perc speed: {} / {}\nspeed diff: {}\nspeed stdev: {}\nregression: {}'.format(min(speeds), percentile(speeds, 5), speeds[-2]-speeds[1], std(speeds), coef[0])) 1855 print('min/5th perc speed: {} / {}\nspeed diff: {}\nspeed stdev: {}\nregression: {}'.format(min(speeds), percentile(speeds, 5), speeds[-2]-speeds[1], std(speeds), coef[0]))