Mercurial Hosting > traffic-intelligence
changeset 1240:bb14f919d1cb
cleaned use of centile (np only) and added info in classify-objects
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)