changeset 1240:bb14f919d1cb

cleaned use of centile (np only) and added info in classify-objects
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 05 Feb 2024 14:14:14 -0500
parents 31173c4699d2
children ab4c72b9475c
files scripts/classify-objects.py scripts/clean-ground-truth.py scripts/compute-clearmot.py scripts/compute-homography.py scripts/create-bounding-boxes.py scripts/create-metadata.py scripts/delete-tables.py scripts/display-synced-trajectories.py scripts/display-trajectories.py scripts/dltrack.py scripts/extract-appearance-images.py scripts/extract-camera-parameters.py scripts/info-video.py scripts/init-tracking.py scripts/learn-motion-patterns.py scripts/learn-poi.py scripts/manual-video-analysis.py scripts/merge-features.py scripts/performance-db.py scripts/performance-lcss.py scripts/play-synced-videos.py scripts/play-video.py scripts/polytracktopdtv.py scripts/rescale-homography.py scripts/safety-analysis.py scripts/test-compute-object-position-from-features.py scripts/train-object-classification.py scripts/undistort-video.py trafficintelligence/indicators.py trafficintelligence/moving.py
diffstat 4 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/classify-objects.py	Fri Oct 06 17:02:32 2023 -0400
+++ b/scripts/classify-objects.py	Mon Feb 05 14:14:14 2024 -0500
@@ -10,7 +10,7 @@
 
 # TODO add mode detection live, add choice of kernel and svm type (to be saved in future classifier format)
 
-parser = argparse.ArgumentParser(description='The program processes indicators for all pairs of road users in the scene')
+parser = argparse.ArgumentParser(description='The program processes indicators for all pairs of road users in the scene', epilog='The integer ids for the categories are stored in the moving module:\n{}'.format(moving.userType2Num))
 parser.add_argument('--cfg', dest = 'configFilename', help = 'name of the configuration file', required = True)
 parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the Sqlite database file (overrides the configuration file)')
 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file (overrides the configuration file)')
--- a/scripts/dltrack.py	Fri Oct 06 17:02:32 2023 -0400
+++ b/scripts/dltrack.py	Mon Feb 05 14:14:14 2024 -0500
@@ -12,7 +12,7 @@
 
 from trafficintelligence import cvutils, moving, storage, utils
 
-parser = argparse.ArgumentParser(description='The program tracks objects using the ultralytics models and trakcers.')#, epilog = 'Either the configuration filename or the other parameters (at least video and database filenames) need to be provided.')
+parser = argparse.ArgumentParser(description='The program tracks objects using the ultralytics models and trakcers.')
 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file', required = True)
 parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the Sqlite database file', required = True)
 parser.add_argument('-m', dest = 'detectorFilename', help = 'name of the detection model file', required = True)
@@ -53,6 +53,9 @@
 lastFrameNum = args.lastFrameNum
 
 success, frame = capture.read()
+if not success:
+    print('Input {} could not be read. Exiting'.format(args.videoFilename))
+    import sys; sys.exit()
 results = model.track(frame, tracker=args.trackerFilename, classes=list(moving.cocoTypeNames.keys()), persist=True, verbose=False)
 # create object with user type and list of 3 features (bottom ones and middle) + projection
 while capture.isOpened() and success and frameNum <= lastFrameNum:
--- a/trafficintelligence/indicators.py	Fri Oct 06 17:02:32 2023 -0400
+++ b/trafficintelligence/indicators.py	Mon Feb 05 14:14:14 2024 -0500
@@ -2,8 +2,7 @@
 '''Class for indicators, temporal indicators, and safety indicators'''
 
 from matplotlib.pyplot import plot, ylim
-from numpy import array, arange, mean, floor, mean
-from scipy import percentile
+from numpy import array, arange, mean, floor, mean, percentile
 
 from trafficintelligence import moving
 from trafficintelligence.utils import LCSS as utilsLCSS
--- a/trafficintelligence/moving.py	Fri Oct 06 17:02:32 2023 -0400
+++ b/trafficintelligence/moving.py	Mon Feb 05 14:14:14 2024 -0500
@@ -4,9 +4,8 @@
 import copy
 from math import sqrt, atan2, cos, sin
 
-from numpy import median, mean, array, arange, zeros, ones, hypot, NaN, std, floor, ceil, float32, argwhere, minimum,  issubdtype, integer as npinteger
+from numpy import median, mean, array, arange, zeros, ones, hypot, NaN, std, floor, ceil, float32, argwhere, minimum,  issubdtype, integer as npinteger, percentile
 from matplotlib.pyplot import plot, text, arrow
-from scipy.stats import scoreatpercentile
 from scipy.spatial.distance import cdist
 from scipy.signal import savgol_filter
 
@@ -1850,7 +1849,7 @@
     def speedDiagnostics(self, framerate = 1., display = False, nInstantsIgnoredAtEnds=0):
         speeds = framerate*self.getSpeeds(nInstantsIgnoredAtEnds)
         coef = utils.linearRegression(list(range(len(speeds))), speeds)
-        print('min/5th perc speed: {} / {}\nspeed diff: {}\nspeed stdev: {}\nregression: {}'.format(min(speeds), scoreatpercentile(speeds, 5), speeds[-2]-speeds[1], std(speeds), coef[0]))
+        print('min/5th perc speed: {} / {}\nspeed diff: {}\nspeed stdev: {}\nregression: {}'.format(min(speeds), percentile(speeds, 5), speeds[-2]-speeds[1], std(speeds), coef[0]))
         if display:
             from matplotlib.pyplot import figure, axis
             figure(1)