tvaLib
Functions | Variables
main Namespace Reference

Functions

def main ()
 main() More...
 

Variables

string version = 'R2.3.0 u. 2017-03-22'
 Serialize/cache data. More...
 
 commands
 Trajectory Utilities. More...
 
 siteIx = sites.interpret(commands.site)[0]
 Setup. More...
 
 camIx = sites[siteIx].interpret(commands.camera)[0]
 
int temp = 0
 Convert .mp4 files to .avi. More...
 
 file_lower = file.lower()
 
 shell
 Concatenate all .avi files and move to parent folder. More...
 
 camIxs = sites[siteIx].interpret(commands.camera)
 Extract images to directory if they do not exist. More...
 
 fileIxs = sites[siteIx][camIx].interpret(commands.file)
 Loop through cameras. More...
 
 camera_matrix
 Loop through sequences. More...
 
 data
 
 dist_coeffs
 
 display
 
 play
 
 freeScalingParameter
 
 imageScalingFactor
 
 verbose
 Analysis. More...
 
 frames
 
 frameRate
 
 fourcc
 
 video_out_fourcc
 
 siteIxs = sites.interpret(commands.site)
 Loop through sites. More...
 
 imageDirectories = dict([(x,os.path.join(sites[siteIx][camIx].getClassificationTrainingBaseDirectory(local['userTypeNames'][x]))) for x in config.class_candidates])
 Data selection. More...
 
 filename = sites[siteIx][camIx][fileIx].getFullClassifiedFilename()
 Check if training data exists. More...
 
 source
 Load video stream. More...
 
 width = int(source.get(3))
 
 height = int(source.get(4))
 
 R = np.identity(3)
 
tuple newImgSize = (int(round(width*sites[siteIx][camIx].camera.imageScalingFactor)), int(round(height*sites[siteIx][camIx].camera.imageScalingFactor)))
 
 new_matrix = deepcopy(sites[siteIx][camIx].camera.camera_matrix.asNpArray())
 
 firstInstant = int(commands.start_time*sites[siteIx][camIx].camera.frameRate)
 Set time bounds. More...
 
 lastInstant
 
 seq_objects = tvaLib.Obj.loadObjects(filename, max_obj_features=config.max_obj_features)
 Load and filter objects. More...
 
 mask
 
 containment_threshold
 
 f_bb_containment_threshold
 
 max_outside_dist
 
 f_bb_max_outside_dist
 
 loopback_verification_frames
 
 f_bb_loopback_ver_frames
 
 bounding_boxes_label
 
 invHomography = tvaLib.Obj.invHomography(sites[siteIx][camIx].getHomography().asNpArray())
 Other preparations. More...
 
tuple frameNum = (obj.getLastInstant() - obj.getFirstInstant())/2 + obj.getFirstInstant()
 For each object, dump middle image. More...
 
 img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR)
 
 imgBox
 
 obj
 
 homography
 
 trainingSamplesPBV = dict((c,[]) for c in config.class_candidates)
 Load images into memory and prepare HoGs. More...
 
 trainingSamplesBV = dict((c,[]) for c in config.class_candidates)
 
 trainingSamplesPB = dict((c,[]) for c in config.class_candidates)
 
 trainingSamplesPV = dict((c,[]) for c in config.class_candidates)
 
 hog = TrafIntCVUtils_HOG(img, rescaleSize=config.class_hogRescaleSize, orientations=config.class_hogNOrientations, pixelsPerCell=config.class_hogNPixelsPerCell, cellsPerBlock=config.class_hogNCellsPerBlock, blockNorm=config.class_hogBlockNorm).tolist()
 
 hy
 
 hx
 
 padding
 Present result (regardless of verbosity) More...
 
 model = TrafIntML_SVM(svmType=config.class_svmType, kernelType=config.class_kernelType, degree=config.class_degree, gamma=config.class_gamma, coef0=config.class_coef0, Cvalue=config.class_cvalue, nu=config.class_nu, p=config.class_svmP)
 Train the Support Vector Machine. More...
 
 result = model.train(np.array([i for s in trainingSamplesPBV.values() for i in s], dtype=np.float32), np.array([k for k,s in zip(trainingSamplesPBV.keys(),trainingSamplesPBV.values()) for i in s], dtype=np.float32), True)
 Loop through sequences. More...
 
 svmModels = dict((svmModelName,TrafIntML_SVM()) for svmModelName in [config.class_PBV_SVMFilename,config.class_BV_SVMFilename,config.class_PB_SVMFilename,config.class_PV_SVMFilename])
 Prepare HoG trained classifier. More...
 
list tally = []
 Administer tests. More...
 
string imageSpaceFrame = ''
 Look for suitable source frame to build homography. More...
 
 homographyFilename
 
 pattern
 
 path
 
 returnList
 
 tsaiCameraSrcPath = tvaLib.crawlDirsForFilePattern(pattern='*.tacal', path=os.getcwd(), returnList=False)
 Attempt to import full camera calibration (.tacal), if it exists. More...
 
 worldPts = None
 
 nPoints
 
 homo
 
 unitsPerPixel
 
 satres
 
 None
 
 fig_name
 
 name
 
 savePath
 
 False
 
 flush = True
 Serialised data loader. More...
 
 saIx = site_analyses.interpret(commands.s_analysis)[0]
 
 view
 Prepare tracking command stack. More...
 
 command
 
 undistort_cmd_stack
 
list cmd_stack
 
string results_path = os.path.splitext(commands.test_track_param_filename)[0]+'-results.txt'
 Load potential tracking parameters. More...
 
dictionary tracking_cases = {}
 
 reader = csv_reader(f, delimiter=',', quotechar='"')
 
 headers = next(reader)
 
 temp_dir
 Delete any potentially pre-existing data in target scratch disk. More...
 
list combined_cmd_stacks = [cmd_stack+['--database-filename', os.path.join(config.temp_dir, sites[siteIx][camIx][fileIx].name+'_'+tvaLib.Parse.clean_file_name(tracking_case)+'.sqlite')]+tracking_cases[tracking_case] for tracking_case in tracking_cases]
 Attempt Tracking. More...
 
 threads
 
 timeout
 
 prependMsg
 
 seq_objects_src = tvaLib.Obj.loadObjects(os.path.join(config.temp_dir, sites[siteIx][camIx][fileIx].name+'_'+tvaLib.Parse.clean_file_name(tracking_case)+'.sqlite'), max_obj_features=config.max_obj_features, suppress_features=True)
 Attempting MOTA analysis. More...
 
 zone
 
 annotations = sites[siteIx][camIx][fileIx].loadAnnotations(indent=4, verbose=commands.verbose)
 Prepare annotations. More...
 
 mot_results = TrafIntMoving.computeClearMOT(annotations, seq_objects_src, config.MOT_max_distance, firstInstant, lastInstant)+(len(annotations),len(seq_objects_src))
 Process MOT calculations mot_results = [motp,mota,dit,mt,mme,fpt,..] and optionally, with returnMatches==True, [..,GT matches, TO matches]. More...
 
list annot_class = [[x.getUserType() for x in annotations].count(i)/float(len(annotations)) for i in range(len(local['userTypeNames']))]
 
list tracked_class = [[x.getUserType() for x in seq_objects_src].count(i)/float(len(seq_objects_src)) for i in range(len(local['userTypeNames']))]
 
 normalisedScore = tvaCompute.normaliseMOTscore(motp=mot_results[0], mota=mot_results[1], n_annot=mot_results[6], n_tracked=mot_results[7], annot_class=annot_class, tracked_class=tracked_class)
 Handle and save scores. More...
 
 draw_max_traj
 
 alignments
 
 sateliteImage
 
 sateliteResolution
 
 labels = {}
 
 local
 Create metadata. More...
 
 figsize
 
 fileIx = None
 Handle mast height calibration. More...
 
list process_file_ids = [''.join(random_choice(string_ascii_uppercase + string_digits) for _ in range(20)) for _ in range(config.MOT_population_size)]
 
list main_cmd_stack
 
dictionary parameters_t
 Optimization parameter space declaration. More...
 
dictionary parameters_g
 
dictionary parameters_f
 
dictionary parameters = {}
 Choose which parameters to pass according to commands. More...
 
 results = tvaLib.command_async_pool(combined_cmd_stacks, threads=commands.threads, timeout=config.s_proc_max_exec_time_in_s, prependMsg=' ', verbose=commands.verbose)
 
 chromosomes = tvaLib.Math.geneticAlg(parameters, config.MOT_population_size)
 For filtering parameters, only one tracking and grouping (using default parameters) is necessary. More...
 
int bestFit = 0
 
 bestSpawn = None
 
int mot_trial = 0
 Auto determine optimization trial number. More...
 
int generationCount = 0
 Optimization loop. More...
 
list config_cmd_stacks = [tvaLib.flatten_list([['--'+x[2:], str(chromosomes[cIx]['params'][x])] for x in chromosomes[cIx]['params'] if x.startswith('t-')]) for cIx in range(len(chromosomes))]
 In this mode, we need to run multiple tracking sequences. More...
 
 s_proc_max_exec_time_in_s
 
 max_obj_features
 
 suppress_features
 
dictionary arguments = {'config':config,'commands':commands,'seq_objects_src':seq_objects_src,'zone':site_analyses[saIx].zone,'mask':sites[siteIx][camIx].mask,'frameRate':sites[siteIx][camIx].camera.frameRate,'camOrigin':sites[siteIx][camIx].camOrigin,'camHeight':sites[siteIx][camIx].camHeight,'chromosomes':chromosomes,'annotations':annotations,'firstInstant':firstInstant,'lastInstant':lastInstant,'process_file_ids':process_file_ids}
 Mota calculation pool try: More...
 
 recipe
 Genetic algorithm. More...
 
 scoreThreshold
 
 config
 
 sites = tvaScene.Sites(config)
 Copy database and rebuild sites. More...
 
 showTrackingCompletion
 
 descriptor
 
 saIxs = site_analyses.interpret(commands.s_analysis)
 
 file_extension
 
dictionary usage_data_types
 Loop through sequences. More...
 
int col_width0 = 35
 
int col_width1 = 20
 
 usage_data = dict((k, []) for k in usage_data_types)
 
list usage_data_other = []
 
bool gotIt = False
 
 site_analyses
 
 objects = sites[siteIx][camIx][fileIx].loadObjects(max_obj=commands.max_obj, max_obj_features=config.max_obj_features, suppress_features=True, indent=4, verbose=commands.verbose)
 Drawing. More...
 
 rotation
 
list input_objects = []
 Ready, steady, go! More...
 
list figures = [tvaVis.TrajSample(input_objects, figsize=config.figsize, traj_colour='random')]
 Basic Figures. More...
 
 file
 
 alternateView
 
 draw_mask
 
bool ignore_alternative_parts = True
 Call alignment drawing function. More...
 
bool confine_to_masks = True
 
 shortcutCamera
 
 True
 
 shortcutSequences
 
 connectorSearchDistance
 
 intersectionDistanceFactor
 
 translationX
 
 translationY
 
 site
 
 cl_align_window_m
 
 f_cl_align_window_m
 
 camera
 
 draw_mast_location
 Handle mast location. More...
 
 max_obj
 
 indent
 
 hli
 Call any HLI drawing functions. More...
 
list tvaHLI = []
 Load appropriate module(s) More...
 
 sequence
 
 satFilename
 
 satRes
 
 fps
 
 intrinsicCameraMatrix
 
 distortionCoefficients
 
 undistortedImageScalingFactor
 
 startTime
 
 eventLabels
 
 objects_uncon = tvaScene.ObjectSpace(spaceType='sites')
 
dictionary dropped_trajectories = {'ie':[], 'bb':[], 'te':[], 'td':[], 'tc':[], 'st':[], 'so':[]}
 
 idx
 Join object space data after filtering to appropriate analysis zone. More...
 
 metadata
 
 s_version = pickle.load(input_data)
 Serialised data loader. More...
 
 seq_dropped_trajectories = pickle.load(input_data)
 
int alignment_passes = 0
 Filter functions. More...
 
 skipTrajectoryContiguityCheck
 
 hard_maxSpeed
 
 f_so_hard_maxSpeed
 
 soft_maxSpeed
 
 f_so_soft_maxSpeed
 
 maxAngle
 
 f_so_max_angle
 
 config_min_traj_len
 
 f_te_config_min_traj_len
 
 minimumSeperationDistance
 
 f_td_min_sep_distance
 
 minimumSeperationVelocity
 
 mps_kmh
 
 maximum_t_seperation
 
 restrict_by_type
 
 passNumber
 
 mps_to_kmh
 
 output
 
 protocol
 
 trajectoryType
 
 companion_objects
 
 matches
 Add matches() method to annotations. More...
 
 class1_results = tvaLib.Obj.computeClassCorrespondance(mot_results[6], annotations, seq_objects)
 
 class2_results = tvaLib.Obj.computeClassCorrespondance(mot_results[7], seq_objects, annotations)
 
 this_run_startTime = min([y.getStartTime() for y in tvaLib.flatten_list([x.metadatas for x in objects.getSubSpacebyId(site_analyses[saIx].site.idx)])])
 TODO: Function to stitch camera trajectories together here. More...
 
 this_run_endTime = max([y.getEndTime() for y in tvaLib.flatten_list([x.metadatas for x in objects.getSubSpacebyId(site_analyses[saIx].site.idx)])])
 
 predictionMethods
 Generate DMP from unconstrained trajectory space. More...
 
 framerate
 
 laneChanges = tvaCompute.computeLaneChanges(objects.getSubSpacebyId(site_analyses[saIx].site.idx), alignments=site_analyses[saIx].site.alignments, mode=1, verbose=commands.verbose)
 
 ODMatrix = tvaCompute.computeLaneChanges(objects.getSubSpacebyId(site_analyses[saIx].site.idx), alignments=site_analyses[saIx].site.alignments, mode=0, verbose=commands.verbose)
 
 ODMatrix_Time = tvaCompute.computeLaneChangesOverTime(objects.getSubSpacebyId(site_analyses[saIx].site.idx), alignments=site_analyses[saIx].site.alignments, mode=0, timestep=15, verbose=commands.verbose)
 
 user_class_variety = tvaCompute.computeClassificationVariety(objects.getSubSpacebyId(site_analyses[saIx].site.idx).getAll(), verbose=commands.verbose)
 
 speed_histo = tvaCompute.computeSpeedHisto(objects.getSubSpacebyId(site_analyses[saIx].site.idx).getAll(), bins=np.arange(0,site_analyses[saIx].max_speed,1), framerate=sites[siteIx][camIx].camera.frameRate, verbose=commands.verbose)
 
 speed_by_lane
 
 slsd
 
 speed_histo_by_lane = tvaCompute.computeSpeedHistoByLane(objects.getSubSpacebyId(site_analyses[saIx].site.idx).getAll(), alignments=site_analyses[saIx].site.alignments, bins=np.arange(0,site_analyses[saIx].max_speed,1), framerate=sites[siteIx][camIx].camera.frameRate, verbose=commands.verbose)
 
 speed_histo_by_class = tvaCompute.computeSpeedHistoByClass(objects.getSubSpacebyId(site_analyses[saIx].site.idx).getAll(), user_class_variety=user_class_variety, bins=np.arange(0,site_analyses[saIx].max_speed,1), framerate=sites[siteIx][camIx].camera.frameRate, verbose=commands.verbose)
 
list userPairs = [tvaScene.UPSpace(spaceType='sites') for x in predictionMethods]
 
 params
 
 seq_userPairs = pickle.load(input_data)
 Conflict method preparation. More...
 
 repop_rate = seq_userPairs.repopulateObjectData(objects_uncon.getSubSpacebyId(sites[siteIx].idx).getSubSpacebyId(sites[siteIx][camIx].idx).getSubSpacebyId(sites[siteIx][camIx][fileIx].idx))
 
 predictionMethod
 
 triage
 
 timeHorizon
 
 indicatorLowerBound
 
 objFrameTable = tvaScene.ObjFrameTable(objects_uncon.getSubSpacebyId(sites[siteIx].idx).getSubSpacebyId(sites[siteIx][camIx].idx).getSubSpacebyId(sites[siteIx][camIx][fileIx].idx))
 
 label
 
 userPair = deepcopy(seq_userPairs)
 Serialize data. More...
 
 userPairNums = list(userPair.roadUserNumbers)
 Time Series Analysis. More...
 
 smallestTTCVal = sys.maxint
 
list localTTCList = []
 
 style
 
 fig_style
 
 size
 
 plot_text_size
 
 family
 
 font_family
 
 xy_bounds
 
 velocity_vector
 
list listAvgTTCy = []
 
list listAvgTTCx = []
 
 plotSettings = tvaVis.plotSettings(style=commands.fig_style, size=config.plot_text_size, family=config.font_family, verbose=commands.verbose)
 Visualisation. More...
 
 fig_lan_suffix
 
 figures_false = sum([1 for figure in figures if figure == False])
 Plot geometry data. More...
 
 fig_format
 Commit. More...
 
 fig_resize
 
 fig_bg_colour
 
list pointTypeArgs
 
list distArgs
 
 listOfExistingUserTypes = list(set([None]+[i for i, x in enumerate([[x.getUserType() for x in objects.getSubSpacebyId(site_analyses[saIx].site.idx).getAll()].count(i) for i in range(len(local['userTypeNames']))]) if x != 0]))
 Generate list of user types present in the scene. More...
 
list userPair_list = userPairs[predictionMethod.idx].getAll()
 For each prediction method... More...
 
 zlabel = local['vis_cp_label_prob']
 For each pair of existing userTypes... More...
 
 label_ratio
 Plot conflict distributions... More...
 
 site_analysis
 Plot DMP stuff. More...
 
 writer = csv_writer(f)
 Output data. More...
 
list VLTableHeadings1 = []
 Prepare headings Edges. More...
 
list VLTableHeadings2 = []
 
 dta15 = site_analyses[saIx].virtual_loops.getEdgeCountVector(i=i, m='m15')
 Start writing. More...
 
dictionary kwargs = {}
 
 hli_args = inspect_getargspec(tvaHLI.main)
 
int error = 0
 Error and exit handling. More...
 
 debug
 

Function Documentation

◆ main()

def main.main ( )

main()

Definition at line 30 of file main.py.

30 def main():
31 
32  try:
33 
37  import sys, os, time, subprocess, logging
38  from importlib import import_module
39  from csv import reader as csv_reader
40  from csv import writer as csv_writer
41  from csv import QUOTE_MINIMAL as csv_QUOTE_MINIMAL
42  from re import search as re_search
43  from shutil import copy as shutil_copy
44  from string import ascii_uppercase as string_ascii_uppercase
45  from string import digits as string_digits
46  from copy import deepcopy
47  from random import choice as random_choice
48  from datetime import datetime
49  from datetime import timedelta
50  from types import MethodType
51  import cPickle as pickle
52  from warnings import filterwarnings
53  filterwarnings('ignore')
54 
55 
56  os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))
57 
58  import include.config as tvaConfig
59  import include.local as tvaLocal
60 
61 
64  commands = tvaConfig.commands()
65  config = tvaConfig.Config(readonly=commands.configreadonly)
66 
67 
70  try: #Colorama, optional, required for Windows if coloured text is desired
71  from colorama import init as colorama_init
72  colorama_init(strip=False)
73  from colorama import Fore, Back, Style
74  except ImportError:
75  Fore = tvaConfig.Fore()
76  Back = tvaConfig.Back()
77  Style = tvaConfig.Style()
78  if(commands.logging or config.disable_colour):
79  config.disable_colour = True
80  Fore = tvaConfig.Fore(forceOff=True)
81  Back = tvaConfig.Back(forceOff=True)
82  Style = tvaConfig.Style(forceOff=True)
83 
84 
87  import include.runtime as tvaRuntime
88 
89 
92  if(not config.advanced_runtime): tvaRuntime.checkDependancies()
93 
94 
99  try: import numpy as np
100  except ImportError: pass
101  #Matplotlib
102  try:
103  from matplotlib import use as mpl_use
104  from matplotlib import get_backend as mpl_get_backend
105  if(commands.f_tk_interface): mpl_use('TkAgg')
106  elif(not commands.f_interface and not config.debug): mpl_use('Agg')
107  import matplotlib.pyplot as plt
108  if(commands.f_interface): commands.max_obj = config.draw_max_traj if commands.max_obj <= 0 else commands.max_obj
109  else: plt.ioff()
110  except (ImportError, RuntimeError) as e: pass
111 
112 
113 
118  if(not config.debug): oldstdout = sys.stdout;sys.stdout = tvaConfig.NullWriter()
119  try:
120  import lib.comp as tvaCompute
121  import lib.draw as tvaDraw
122  import lib.filt as tvaFilter
123  import lib.int as tvaInteraction
124  import lib.scene as tvaScene
125  import lib.stat as tvaStats
126  import lib.tools as tvaLib
127  import lib.vis as tvaVis
128  finally:
129  if(not config.debug): sys.stdout = oldstdout #Re-enable output
130 
131 
134  if(config.debug): logging.basicConfig(level=logging.DEBUG, format='[%(levelname)s] (%(threadName)-10s) %(message)s')
135 
136 
139  if(commands.dir): config.dir = commands.dir
140  if(commands.dbn): config.dbn = commands.dbn
141  if(commands.language): config.language = commands.language
142  local = tvaLocal.Local(config.language)
143  #Override module colour options
144  tvaLib.Fore = Fore;tvaLib.Back = Back;tvaLib.Style = Style
145  tvaRuntime.Fore = Fore;tvaRuntime.Back = Back;tvaRuntime.Style = Style
146 
147  if(not commands.configreadonly and (not config.path_to_trafint or (config.path_to_trafint and not os.path.exists(config.path_to_trafint)))):
148  try:
149  import Tkinter as tk
150  from tkFileDialog import askdirectory
151  root = tk.Tk()
152  root.withdraw()
153  config.setValue('path_to_trafint',askdirectory(title=local['UI_dialogue_title_sel_TI'], initialdir=''))
154  if(config.path_to_trafint): config.write()
155  except: raise Exception, [2840, 'Could not find Traffic Intelligence (at "'+config.path_to_trafint+'") and interface failed to load.']
156 
157  if(not commands.configreadonly and not os.path.exists(os.path.join(config.dir, config.dbn))):
158  try:
159  import Tkinter as tk
160  from tkFileDialog import askopenfilename
161  root = tk.Tk()
162  root.withdraw()
163  except: raise Exception, [2841, 'Could not find video database (at "'+os.path.join(config.dir, config.dbn)+'") and interface failed to load.']
164  dbFilename = askopenfilename(title=local['UI_dialogue_title_sel_db'], filetypes=[('SQLITE', '.sqlite')])
165  if(not dbFilename): raise Exception, [201, 'No suitable database chosen ('+os.path.join(config.dir, config.dbn)+' could not be found).']
166  config.dir = os.path.split(dbFilename)[0]
167  config.dbn = os.path.split(dbFilename)[1]
168  if(not commands.dir and not commands.dbn):
169  if(config.dir or config.dbn): config.write()
170 
171  try:
172  sites = tvaScene.Sites(config)
173  site_analyses = tvaScene.SiteAnalyses(config, sites=sites)
174  except:
175  if(config.debug):
176  sites = tvaScene.Sites(config)
177  site_analyses = tvaScene.SiteAnalyses(config, sites=sites)
178  else: raise Exception, [2842, 'Metadata database failed to load and is possibly corrupt.']
179  #sites.exportToCode() ## Use this manual override to backport scene.sqlite data to code to regenerate a clean scene.sqlite
180  #site_analyses.exportToCode() ## Use this manual override to backport scene.sqlite data to code to regenerate a clean scene.sqlite
181  commands.indicators = tvaLib.Parse.list1D(commands.indicators, i_type='int')
182  commands.sample_traj = tvaLib.Parse.list1D(commands.sample_traj, i_type='int')
183 
184  if(commands.logging):
185  if(commands.verbose >= 1): tvaLib.printNotice('The --log command has been selected. ALL program output will be dumped to run.log which will be moved to the relevant analysis folder if possible. No further output will be displayed onscreen.', local['gen_notice'])
186  if(commands.verbose < 2): commands.verbose = 2
187  commands.stat = True
188  if(commands.save_data_flush or commands.save_data_flush_objects): log_mode = 'w'
189  else: log_mode = 'a'
190  oldstdout = sys.stdout
191  process_file_id = ''.join(random_choice(string_ascii_uppercase + string_digits) for _ in range(20))
192  sys.stdout = open('run_'+process_file_id+'.log', log_mode)
193 
194  config.version = tvaLib.Parse.versionFromHgCommit(version)
195  if(commands.verbose): print('Running tvaLib version '+config.version)
196  if(config.debug): logging.debug('Using matplotlib backend: '+mpl_get_backend())
197  if(commands.verbose): print('Using database: '+os.path.join(config.dir,config.dbn))
198 
199 
Definition: int.py:1
Definition: stat.py:1
Definition: comp.py:1
def main()
main()
Definition: draw.py:1
def join(obj1, obj2, postSmoothing=True)
Definition: tools_obj.py:816
Definition: vis.py:1
Definition: filt.py:1

Variable Documentation

◆ alignment_passes

main.alignment_passes = 0

Filter functions.

Definition at line 1535 of file main.py.

◆ alignments

main.alignments

Definition at line 644 of file main.py.

◆ alternateView

main.alternateView

Definition at line 1165 of file main.py.

◆ annot_class

list main.annot_class = [[x.getUserType() for x in annotations].count(i)/float(len(annotations)) for i in range(len(local['userTypeNames']))]

Definition at line 636 of file main.py.

◆ annotations

main.annotations = sites[siteIx][camIx][fileIx].loadAnnotations(indent=4, verbose=commands.verbose)

Prepare annotations.

Statistics.

Prepare annotations6.

Definition at line 629 of file main.py.

◆ arguments

Mota calculation pool try:

Definition at line 830 of file main.py.

◆ bestFit

main.bestFit = 0

Definition at line 773 of file main.py.

◆ bestSpawn

main.bestSpawn = None

Definition at line 774 of file main.py.

◆ bounding_boxes_label

main.bounding_boxes_label

Definition at line 332 of file main.py.

◆ camera

main.camera

Definition at line 1345 of file main.py.

◆ camera_matrix

main.camera_matrix

Loop through sequences.

Definition at line 272 of file main.py.

◆ camIx

main.camIx = sites[siteIx].interpret(commands.camera)[0]

Definition at line 210 of file main.py.

◆ camIxs

main.camIxs = sites[siteIx].interpret(commands.camera)

Extract images to directory if they do not exist.

Loop through cameras.

Loop through sites.

Definition at line 241 of file main.py.

◆ chromosomes

main.chromosomes = tvaLib.Math.geneticAlg(parameters, config.MOT_population_size)

For filtering parameters, only one tracking and grouping (using default parameters) is necessary.

Definition at line 772 of file main.py.

◆ cl_align_window_m

main.cl_align_window_m

Definition at line 1343 of file main.py.

◆ class1_results

main.class1_results = tvaLib.Obj.computeClassCorrespondance(mot_results[6], annotations, seq_objects)

Definition at line 1728 of file main.py.

◆ class2_results

main.class2_results = tvaLib.Obj.computeClassCorrespondance(mot_results[7], seq_objects, annotations)

Definition at line 1729 of file main.py.

◆ cmd_stack

list main.cmd_stack
Initial value:
1 = [command,
2  sites[siteIx][camIx].getFullConfigurationFilename(),
3  '--video-filename', sites[siteIx][camIx][fileIx].getFullVideoFilename(),
4  '--mask-filename', sites[siteIx][camIx].getFullMaskFilename(),
5  '--homography', sites[siteIx][camIx].getFullHomographyFilename(),
6  '--frame1', str(int(commands.start_time*sites[siteIx][camIx].camera.frameRate)),
7  '--nframes', str(int(commands.time*sites[siteIx][camIx].camera.frameRate)),
8  '--display', view]+undistort_cmd_stack

Definition at line 575 of file main.py.

◆ col_width0

int main.col_width0 = 35

Definition at line 1053 of file main.py.

◆ col_width1

int main.col_width1 = 20

Definition at line 1054 of file main.py.

◆ combined_cmd_stacks

list main.combined_cmd_stacks = [cmd_stack+['--database-filename', os.path.join(config.temp_dir, sites[siteIx][camIx][fileIx].name+'_'+tvaLib.Parse.clean_file_name(tracking_case)+'.sqlite')]+tracking_cases[tracking_case] for tracking_case in tracking_cases]

Attempt Tracking.

Loop through sequences to generate list of combined command stacks.

For grouping parameters only, only one tracking (using default parameters) is necessary, or use prebuilt file, if available.

Definition at line 604 of file main.py.

◆ command

main.command

Definition at line 571 of file main.py.

◆ commands

main.commands

Trajectory Utilities.

CORE.

Video Annotation.

Call mast calibration function.

Call object highlighting function.

Call alignment snapping function.

Call trajectory transformation drawing function.

Call vl_coordinates drawing function.

Call zone drawing function.

Call bound auto-completion function.

Call bound drawing function.

Call mask drawing function.

Plot mode interrupt.

Meta data annotation and drawing functions.

TI data cleanup.

tva data cleanup

Run tracking.

Compute homography.

Data selection.

Loop through sequences.

Remove temporary avi files.

Concatenate mp4 files

Frame dump

Undistort video footage

Preprocess commands

Preflight

Any sequences related to the analysis are loaded into memory TODO: handle multiple site analysis (we can only load one in memory for now)

Definition at line 208 of file main.py.

◆ companion_objects

main.companion_objects

Definition at line 1643 of file main.py.

◆ config

main.config

Definition at line 889 of file main.py.

◆ config_cmd_stacks

list main.config_cmd_stacks = [tvaLib.flatten_list([['--'+x[2:], str(chromosomes[cIx]['params'][x])] for x in chromosomes[cIx]['params'] if x.startswith('t-')]) for cIx in range(len(chromosomes))]

In this mode, we need to run multiple tracking sequences.

Definition at line 795 of file main.py.

◆ config_min_traj_len

main.config_min_traj_len

Definition at line 1546 of file main.py.

◆ confine_to_masks

bool main.confine_to_masks = True

Definition at line 1231 of file main.py.

◆ connectorSearchDistance

main.connectorSearchDistance

Definition at line 1259 of file main.py.

◆ containment_threshold

main.containment_threshold

Definition at line 332 of file main.py.

◆ data

main.data

Definition at line 272 of file main.py.

◆ debug

main.debug

Definition at line 2397 of file main.py.

◆ descriptor

main.descriptor

Definition at line 936 of file main.py.

◆ display

main.display

Definition at line 272 of file main.py.

◆ dist_coeffs

main.dist_coeffs

Definition at line 272 of file main.py.

◆ distArgs

list main.distArgs
Initial value:
1 = [{'method':0, 'percentile':0.0, 'label':local['int_all_instants']},
2  {'method':1, 'percentile':0.15, 'label':local['int_unique_15th']},
3  {'method':1, 'percentile':0.0, 'label':local['int_unique_min']},
4  {'method':3, 'percentile':1.0, 'label':local['int_unique_max_prob']}]

Definition at line 2147 of file main.py.

◆ distortionCoefficients

main.distortionCoefficients

Definition at line 1439 of file main.py.

◆ draw_mask

main.draw_mask

Definition at line 1165 of file main.py.

◆ draw_mast_location

main.draw_mast_location

Handle mast location.

Definition at line 1360 of file main.py.

◆ draw_max_traj

main.draw_max_traj

Definition at line 644 of file main.py.

◆ dropped_trajectories

main.dropped_trajectories = {'ie':[], 'bb':[], 'te':[], 'td':[], 'tc':[], 'st':[], 'so':[]}

Definition at line 1475 of file main.py.

◆ dta15

list main.dta15 = site_analyses[saIx].virtual_loops.getEdgeCountVector(i=i, m='m15')

Start writing.

Definition at line 2278 of file main.py.

◆ error

int main.error = 0

Error and exit handling.

Normal program exit.

User interruption

Definition at line 2386 of file main.py.

◆ eventLabels

main.eventLabels

Definition at line 1442 of file main.py.

◆ f_bb_containment_threshold

main.f_bb_containment_threshold

Definition at line 332 of file main.py.

◆ f_bb_loopback_ver_frames

main.f_bb_loopback_ver_frames

Definition at line 332 of file main.py.

◆ f_bb_max_outside_dist

main.f_bb_max_outside_dist

Definition at line 332 of file main.py.

◆ f_cl_align_window_m

main.f_cl_align_window_m

Definition at line 1343 of file main.py.

◆ f_so_hard_maxSpeed

main.f_so_hard_maxSpeed

Definition at line 1545 of file main.py.

◆ f_so_max_angle

main.f_so_max_angle

Definition at line 1545 of file main.py.

◆ f_so_soft_maxSpeed

main.f_so_soft_maxSpeed

Definition at line 1545 of file main.py.

◆ f_td_min_sep_distance

main.f_td_min_sep_distance

Definition at line 1547 of file main.py.

◆ f_te_config_min_traj_len

main.f_te_config_min_traj_len

Definition at line 1546 of file main.py.

◆ False

main.False

Definition at line 522 of file main.py.

◆ family

main.family

Definition at line 2016 of file main.py.

◆ fig_bg_colour

main.fig_bg_colour

Definition at line 2105 of file main.py.

◆ fig_format

main.fig_format

Commit.

Definition at line 2105 of file main.py.

◆ fig_lan_suffix

main.fig_lan_suffix

Definition at line 2051 of file main.py.

◆ fig_name

main.fig_name

Definition at line 511 of file main.py.

◆ fig_resize

main.fig_resize

Definition at line 2105 of file main.py.

◆ fig_style

main.fig_style

Definition at line 2016 of file main.py.

◆ figsize

main.figsize

Definition at line 644 of file main.py.

◆ figures

list main.figures = [tvaVis.TrajSample(input_objects, figsize=config.figsize, traj_colour='random')]

Basic Figures.

Plot Conflict/SSM Figures.

Plot Dropped Trajectories and Other Filtering Information.

Definition at line 1143 of file main.py.

◆ figures_false

main.figures_false = sum([1 for figure in figures if figure == False])

Plot geometry data.

Timeseries.

Trajectory Sorting.

Plot Tracking results Plot Speed Maps Plot OD Stuff Plot Infraction Stuff TODO: figures.append(tvaVis.traj2D([objects.getAll()[i] for i in infractions.WrongWay], draw_max_traj=config.draw_max_traj, xy_bounds=site_analyses[saIx].xy_bounds, alignments=site_analyses[saIx].site.alignments, mask=site_analyses[saIx].getCombinedMasks(), zone=site_analyses[saIx].zone, labels=True, objects_uncon=objects_uncon.getAll(), velocity_vector=False, local=local, fig_name='Infractions (wrong way)', figsize=config.figsize, plotSettings=plotSettings)) tvaVis.traj3D(tvaLib.Obj.numsAsObjects(objects[camOIx].getAll(), list_stopped), draw_max_traj=config.draw_max_traj, xy_bounds=site_analyses[saIx].xy_bounds, alignments=site_analyses[saIx].site].alignments, mask=site_analyses[saIx].getCombinedMasks(), labels=True, local=local, fig_name='Trajectories with dwell time', figsize=config.figsize) Plot MOT Stuff Count aborted figures

Filtering Count aborted figures

Count aborted figures

Definition at line 2101 of file main.py.

◆ file

main.file

Definition at line 1156 of file main.py.

◆ file_extension

main.file_extension

Definition at line 1002 of file main.py.

◆ file_lower

main.file_lower = file.lower()

Definition at line 220 of file main.py.

◆ fileIx

main.fileIx = None

Handle mast height calibration.

Prepare data

Definition at line 664 of file main.py.

◆ fileIxs

list main.fileIxs = sites[siteIx][camIx].interpret(commands.file)

Loop through cameras.

Loop through sequences.

Skip to first sequence with available ground truth, if it exists.

Definition at line 244 of file main.py.

◆ filename

string main.filename = sites[siteIx][camIx][fileIx].getFullClassifiedFilename()

Check if training data exists.

Check if objects exist in memory.

Execute selected prediction methods

Definition at line 302 of file main.py.

◆ firstInstant

main.firstInstant = int(commands.start_time*sites[siteIx][camIx].camera.frameRate)

Set time bounds.

Loop through sequences to find an appropriate sequence.

Sequence parameters

Definition at line 325 of file main.py.

◆ flush

bool main.flush = True

Serialised data loader.

Definition at line 529 of file main.py.

◆ font_family

main.font_family

Definition at line 2016 of file main.py.

◆ fourcc

main.fourcc

Definition at line 275 of file main.py.

◆ fps

main.fps

Definition at line 1437 of file main.py.

◆ frameNum

main.frameNum = (obj.getLastInstant() - obj.getFirstInstant())/2 + obj.getFirstInstant()

For each object, dump middle image.

Definition at line 344 of file main.py.

◆ frameRate

main.frameRate

Definition at line 275 of file main.py.

◆ framerate

main.framerate

Definition at line 1804 of file main.py.

◆ frames

main.frames

Definition at line 275 of file main.py.

◆ freeScalingParameter

main.freeScalingParameter

Definition at line 272 of file main.py.

◆ generationCount

int main.generationCount = 0

Optimization loop.

Definition at line 786 of file main.py.

◆ gotIt

bool main.gotIt = False

Definition at line 1061 of file main.py.

◆ hard_maxSpeed

main.hard_maxSpeed

Definition at line 1545 of file main.py.

◆ headers

main.headers = next(reader)

Definition at line 590 of file main.py.

◆ height

main.height = int(source.get(4))

Definition at line 315 of file main.py.

◆ hli

main.hli

Call any HLI drawing functions.

Definition at line 1386 of file main.py.

◆ hli_args

main.hli_args = inspect_getargspec(tvaHLI.main)

Definition at line 2359 of file main.py.

◆ hog

main.hog = TrafIntCVUtils_HOG(img, rescaleSize=config.class_hogRescaleSize, orientations=config.class_hogNOrientations, pixelsPerCell=config.class_hogNPixelsPerCell, cellsPerBlock=config.class_hogNCellsPerBlock, blockNorm=config.class_hogBlockNorm).tolist()

Definition at line 393 of file main.py.

◆ homo

main.homo

Definition at line 511 of file main.py.

◆ homography

main.homography

Definition at line 350 of file main.py.

◆ homographyFilename

main.homographyFilename

Definition at line 493 of file main.py.

◆ hx

main.hx

Definition at line 401 of file main.py.

◆ hy

main.hy

Definition at line 401 of file main.py.

◆ idx

main.idx

Join object space data after filtering to appropriate analysis zone.

Loop through sequences.

loop through cameras

Skip analysis zone selection if generating motion prediction patterns

Definition at line 1483 of file main.py.

◆ ignore_alternative_parts

bool main.ignore_alternative_parts = True

Call alignment drawing function.

Definition at line 1230 of file main.py.

◆ imageDirectories

main.imageDirectories = dict([(x,os.path.join(sites[siteIx][camIx].getClassificationTrainingBaseDirectory(local['userTypeNames'][x]))) for x in config.class_candidates])

Data selection.

Definition at line 295 of file main.py.

◆ imageScalingFactor

main.imageScalingFactor

Definition at line 272 of file main.py.

◆ imageSpaceFrame

main.imageSpaceFrame = ''

Look for suitable source frame to build homography.

Definition at line 483 of file main.py.

◆ img

main.img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR)

Definition at line 346 of file main.py.

◆ imgBox

main.imgBox

Definition at line 350 of file main.py.

◆ indent

main.indent

Definition at line 1374 of file main.py.

◆ indicatorLowerBound

main.indicatorLowerBound

Definition at line 1938 of file main.py.

◆ input_objects

main.input_objects = []

Ready, steady, go!

Definition at line 1139 of file main.py.

◆ intersectionDistanceFactor

main.intersectionDistanceFactor

Definition at line 1259 of file main.py.

◆ intrinsicCameraMatrix

main.intrinsicCameraMatrix

Definition at line 1438 of file main.py.

◆ invHomography

main.invHomography = tvaLib.Obj.invHomography(sites[siteIx][camIx].getHomography().asNpArray())

Other preparations.

Definition at line 336 of file main.py.

◆ kwargs

dictionary main.kwargs = {}

Definition at line 2358 of file main.py.

◆ label

main.label

Definition at line 1952 of file main.py.

◆ label_ratio

main.label_ratio

Plot conflict distributions...

Definition at line 2204 of file main.py.

◆ labels

dictionary main.labels = {}

Definition at line 644 of file main.py.

◆ laneChanges

main.laneChanges = tvaCompute.computeLaneChanges(objects.getSubSpacebyId(site_analyses[saIx].site.idx), alignments=site_analyses[saIx].site.alignments, mode=1, verbose=commands.verbose)

Definition at line 1826 of file main.py.

◆ lastInstant

main.lastInstant

Definition at line 326 of file main.py.

◆ listAvgTTCx

list main.listAvgTTCx = []

Definition at line 2022 of file main.py.

◆ listAvgTTCy

list main.listAvgTTCy = []

Definition at line 2021 of file main.py.

◆ listOfExistingUserTypes

main.listOfExistingUserTypes = list(set([None]+[i for i, x in enumerate([[x.getUserType() for x in objects.getSubSpacebyId(site_analyses[saIx].site.idx).getAll()].count(i) for i in range(len(local['userTypeNames']))]) if x != 0]))

Generate list of user types present in the scene.

Definition at line 2153 of file main.py.

◆ local

main.local

Create metadata.

Definition at line 644 of file main.py.

◆ localTTCList

list main.localTTCList = []

Definition at line 2004 of file main.py.

◆ loopback_verification_frames

main.loopback_verification_frames

Definition at line 332 of file main.py.

◆ main_cmd_stack

list main.main_cmd_stack
Initial value:
1 = [command,
2  site_analyses[saIx].getFullConfigurationFilename(config.output_folder),
3  '--video-filename', sites[siteIx][camIx][fileIx].getFullVideoFilename(),
4  '--mask-filename', sites[siteIx][camIx].getFullMaskFilename(),
5  '--homography', sites[siteIx][camIx].getFullHomographyFilename(),
6  '--frame1', str(int(commands.start_time*sites[siteIx][camIx].camera.frameRate)),
7  '--nframes', str(int(commands.time*sites[siteIx][camIx].camera.frameRate)),
8  '--display', view]

Definition at line 691 of file main.py.

◆ mask

main.mask

Definition at line 332 of file main.py.

◆ matches

main.matches

Add matches() method to annotations.

Definition at line 1723 of file main.py.

◆ max_obj

main.max_obj

Definition at line 1374 of file main.py.

◆ max_obj_features

main.max_obj_features

Definition at line 821 of file main.py.

◆ max_outside_dist

main.max_outside_dist

Definition at line 332 of file main.py.

◆ maxAngle

main.maxAngle

Definition at line 1545 of file main.py.

◆ maximum_t_seperation

main.maximum_t_seperation

Definition at line 1548 of file main.py.

◆ metadata

main.metadata

Definition at line 1483 of file main.py.

◆ minimumSeperationDistance

main.minimumSeperationDistance

Definition at line 1547 of file main.py.

◆ minimumSeperationVelocity

main.minimumSeperationVelocity

Definition at line 1547 of file main.py.

◆ model

main.model = TrafIntML_SVM(svmType=config.class_svmType, kernelType=config.class_kernelType, degree=config.class_degree, gamma=config.class_gamma, coef0=config.class_coef0, Cvalue=config.class_cvalue, nu=config.class_nu, p=config.class_svmP)

Train the Support Vector Machine.

Definition at line 407 of file main.py.

◆ mot_results

main.mot_results = TrafIntMoving.computeClearMOT(annotations, seq_objects_src, config.MOT_max_distance, firstInstant, lastInstant)+(len(annotations),len(seq_objects_src))

Process MOT calculations mot_results = [motp,mota,dit,mt,mme,fpt,..] and optionally, with returnMatches==True, [..,GT matches, TO matches].

Definition at line 635 of file main.py.

◆ mot_trial

int main.mot_trial = 0

Auto determine optimization trial number.

Definition at line 778 of file main.py.

◆ mps_kmh

main.mps_kmh

Definition at line 1547 of file main.py.

◆ mps_to_kmh

main.mps_to_kmh

Definition at line 1573 of file main.py.

◆ name

main.name

Definition at line 511 of file main.py.

◆ new_matrix

main.new_matrix = deepcopy(sites[siteIx][camIx].camera.camera_matrix.asNpArray())

Definition at line 319 of file main.py.

◆ newImgSize

tuple main.newImgSize = (int(round(width*sites[siteIx][camIx].camera.imageScalingFactor)), int(round(height*sites[siteIx][camIx].camera.imageScalingFactor)))

Definition at line 318 of file main.py.

◆ None

main.None

Definition at line 511 of file main.py.

◆ normalisedScore

main.normalisedScore = tvaCompute.normaliseMOTscore(motp=mot_results[0], mota=mot_results[1], n_annot=mot_results[6], n_tracked=mot_results[7], annot_class=annot_class, tracked_class=tracked_class)

Handle and save scores.

Definition at line 638 of file main.py.

◆ nPoints

main.nPoints

Definition at line 511 of file main.py.

◆ obj

main.obj

Definition at line 350 of file main.py.

◆ objects

list main.objects = sites[siteIx][camIx][fileIx].loadObjects(max_obj=commands.max_obj, max_obj_features=config.max_obj_features, suppress_features=True, indent=4, verbose=commands.verbose)

Drawing.

Sanity checks.

Sanity-checks.

Prepare data

Load and pre-process object data into object space

Definition at line 1135 of file main.py.

◆ objects_uncon

main.objects_uncon = tvaScene.ObjectSpace(spaceType='sites')

Definition at line 1474 of file main.py.

◆ objFrameTable

main.objFrameTable = tvaScene.ObjFrameTable(objects_uncon.getSubSpacebyId(sites[siteIx].idx).getSubSpacebyId(sites[siteIx][camIx].idx).getSubSpacebyId(sites[siteIx][camIx][fileIx].idx))

Definition at line 1951 of file main.py.

◆ ODMatrix

main.ODMatrix = tvaCompute.computeLaneChanges(objects.getSubSpacebyId(site_analyses[saIx].site.idx), alignments=site_analyses[saIx].site.alignments, mode=0, verbose=commands.verbose)

Definition at line 1827 of file main.py.

◆ ODMatrix_Time

main.ODMatrix_Time = tvaCompute.computeLaneChangesOverTime(objects.getSubSpacebyId(site_analyses[saIx].site.idx), alignments=site_analyses[saIx].site.alignments, mode=0, timestep=15, verbose=commands.verbose)

Definition at line 1828 of file main.py.

◆ output

main.output

Definition at line 1583 of file main.py.

◆ padding

main.padding

Present result (regardless of verbosity)

Definition at line 402 of file main.py.

◆ parameters

dictionary main.parameters = {}

Choose which parameters to pass according to commands.

Definition at line 733 of file main.py.

◆ parameters_f

dictionary main.parameters_f
Initial value:
1 = {'f-bb-containment_threshold': [0.7,0.95,float], #closer to 0.9
2  'f-bb-loopback_verification_frames': [5,40,int], #closer to 20
3  'f-so-hard_maxSpeed': [4.0,8.0,float], #closer to 6.0
4  'f-so-soft_maxSpeed': [1.0,3.0,float], #closer to 2.0
5  'f-so-max_angle': [35.0,90.0,float], #closer to 45.0
6  'f-te-config_min_traj_len': [10,30,int], #closer to 20
7  'f-td-minimumSeperationDistance': [3.0,10.0,float], #closer to 8.0
8  'f-td-minimumSeperationVelocity': [2.0,12.0,float], #closer to 8.0
9  'f-fs-max_dwell_time': [0.2,2.0,float], #closer to 0.66
10  'f-fs-search_radius': [2.0,12.0,float], #closer to 8.0
11  'f-fs-search_window': [10,100,float], #closer to 50
12  'f-fs-speed_adj_factor': [500.0,1500.00,float], #closer to 1000.0
13  'f-fs-speed_similarity_limit': [0.1,0.6,float], #closer to 0.3
14  'f-fs-speed_sim_limit_min': [5.0,20.0,float], #closer to 10.0
15  'f-fs-stop_speed_detection_limit': [2.0,7.0,float], #closer to 5.5
16  'f-fs-angle_similairty_deg': [40.0,120.0,float] #closer to 80.0
17  }

Definition at line 714 of file main.py.

◆ parameters_g

dictionary main.parameters_g
Initial value:
1 = {'t-min-feature-time': [1,15,int], #closer to 3
2  't-mm-connection-distance': [1.2,5.0,float], #closer to 1.85
3  't-mm-segmentation-distance': [0.5,5,float], #closer to 2.2
4  't-min-nfeatures-group': [1,5,float] #closer to 3
5  }

Definition at line 709 of file main.py.

◆ parameters_t

dictionary main.parameters_t
Initial value:
1 = {'t-min-feature-distanceklt': [0,6,float], #closer to 1
2  't-feature-quality': [0,0.4,float], #closer to 0.1
3  't-window-size': [3,10,int], #closer to 6, but unpredictable
4  }

Optimization parameter space declaration.

Definition at line 705 of file main.py.

◆ params

main.params

Definition at line 1898 of file main.py.

◆ passNumber

main.passNumber

Definition at line 1552 of file main.py.

◆ path

main.path

Definition at line 497 of file main.py.

◆ pattern

main.pattern

Definition at line 497 of file main.py.

◆ play

main.play

Definition at line 272 of file main.py.

◆ plot_text_size

main.plot_text_size

Definition at line 2016 of file main.py.

◆ plotSettings

main.plotSettings = tvaVis.plotSettings(style=commands.fig_style, size=config.plot_text_size, family=config.font_family, verbose=commands.verbose)

Visualisation.

Set plotting style

Definition at line 2050 of file main.py.

◆ pointTypeArgs

list main.pointTypeArgs
Initial value:
1 = [{'ptype':'CP', 'maxIndThreshold':sys.maxint},
2  {'ptype':'CP', 'maxIndThreshold':config.TTCthreshSeconds*sites[siteIx][camIx].camera.frameRate},
3  {'ptype':'CZ', 'maxIndThreshold':sys.maxint}]

Definition at line 2144 of file main.py.

◆ predictionMethod

main.predictionMethod

Definition at line 1937 of file main.py.

◆ predictionMethods

main.predictionMethods
Initial value:
1 = tvaConfig.PredictionMethods(maxSpeed=site_analyses[saIx].max_speed,
2  timeHorizon=config.timehorizon,
3  xy_bounds=tvaLib.Obj.genXY_bounds(objects_uncon.getAll()),
4  allowImport=not commands.save_data_gen_dmp,
5  importLocations=[sites[siteIx][camIx].getBaseDirectory()], #site_analyses[saIx].getFullResultsFolder()
6  customSpeedRange=[x*sites[siteIx][camIx].camera.frameRate*config.mps_kmh for x in tvaLib.Math.getPercintileBinsFromList(objects.getSubSpacebyId(site_analyses[saIx].site.idx).getAllSpeeds(flatList=True), bins=7, includeLeftEdge=True)],
7  results_path=site_analyses[saIx].getFullResultsFolder(),
8  minSampleSize=config.pred_minSampleSize,
9  probRetentionThreshold=config.pred_probability_threshold,
10  verbose=commands.verbose,
11  version=config.version)

Generate DMP from unconstrained trajectory space.

Conflict/SSM Calculations.

Note that trajectories use objects_uncon space, i.e. trajectories unbounded by an analysis zone. Instead, the analysis zone is used to bound Collision Points.

Definition at line 1792 of file main.py.

◆ prependMsg

main.prependMsg

Definition at line 608 of file main.py.

◆ process_file_ids

list main.process_file_ids = [''.join(random_choice(string_ascii_uppercase + string_digits) for _ in range(20)) for _ in range(config.MOT_population_size)]

Definition at line 666 of file main.py.

◆ protocol

main.protocol

Definition at line 1583 of file main.py.

◆ R

main.R = np.identity(3)

Definition at line 317 of file main.py.

◆ reader

main.reader = csv_reader(f, delimiter=',', quotechar='"')

Definition at line 589 of file main.py.

◆ recipe

main.recipe

Genetic algorithm.

Definition at line 869 of file main.py.

◆ repop_rate

main.repop_rate = seq_userPairs.repopulateObjectData(objects_uncon.getSubSpacebyId(sites[siteIx].idx).getSubSpacebyId(sites[siteIx][camIx].idx).getSubSpacebyId(sites[siteIx][camIx][fileIx].idx))

Definition at line 1900 of file main.py.

◆ restrict_by_type

main.restrict_by_type

Definition at line 1552 of file main.py.

◆ result

main.result = model.train(np.array([i for s in trainingSamplesPBV.values() for i in s], dtype=np.float32), np.array([k for k,s in zip(trainingSamplesPBV.keys(),trainingSamplesPBV.values()) for i in s], dtype=np.float32), True)

Loop through sequences.

Drawing.

Rebuild file structure.

Remove serialized data (in any circumstance) Remove all other data

Additional functionality if source database available on disk Preflight checks

Definition at line 408 of file main.py.

◆ results

main.results = tvaLib.command_async_pool(combined_cmd_stacks, threads=commands.threads, timeout=config.s_proc_max_exec_time_in_s, prependMsg=' ', verbose=commands.verbose)

Definition at line 761 of file main.py.

◆ results_path

string main.results_path = os.path.splitext(commands.test_track_param_filename)[0]+'-results.txt'

Load potential tracking parameters.

Definition at line 585 of file main.py.

◆ returnList

main.returnList

Definition at line 497 of file main.py.

◆ rotation

main.rotation

Definition at line 1137 of file main.py.

◆ s_proc_max_exec_time_in_s

main.s_proc_max_exec_time_in_s

Definition at line 817 of file main.py.

◆ s_version

main.s_version = pickle.load(input_data)

Serialised data loader.

Look for serialised/cached data.

Definition at line 1500 of file main.py.

◆ saIx

main.saIx = site_analyses.interpret(commands.s_analysis)[0]

Definition at line 547 of file main.py.

◆ saIxs

main.saIxs = site_analyses.interpret(commands.s_analysis)

Definition at line 998 of file main.py.

◆ sateliteImage

main.sateliteImage

Definition at line 644 of file main.py.

◆ sateliteResolution

main.sateliteResolution

Definition at line 644 of file main.py.

◆ satFilename

main.satFilename

Definition at line 1433 of file main.py.

◆ satres

main.satres

Definition at line 511 of file main.py.

◆ satRes

main.satRes

Definition at line 1434 of file main.py.

◆ savePath

main.savePath

Definition at line 522 of file main.py.

◆ scoreThreshold

main.scoreThreshold

Definition at line 869 of file main.py.

◆ seq_dropped_trajectories

dictionary main.seq_dropped_trajectories = pickle.load(input_data)

Definition at line 1510 of file main.py.

◆ seq_objects

main.seq_objects = tvaLib.Obj.loadObjects(filename, max_obj_features=config.max_obj_features)

Load and filter objects.

Lock in unconstrained objects used for conflict analysis (and other tasks) here.

Memory-optimization functions.

Update meta data.

SQLITE loader.

Move on if no trajectories left... Statistics

Definition at line 330 of file main.py.

◆ seq_objects_src

main.seq_objects_src = tvaLib.Obj.loadObjects(os.path.join(config.temp_dir, sites[siteIx][camIx][fileIx].name+'_'+tvaLib.Parse.clean_file_name(tracking_case)+'.sqlite'), max_obj_features=config.max_obj_features, suppress_features=True)

Attempting MOTA analysis.

Definition at line 614 of file main.py.

◆ seq_userPairs

main.seq_userPairs = pickle.load(input_data)

Conflict method preparation.

Join userPair space data.

Conflict method calculation

Definition at line 1899 of file main.py.

◆ sequence

main.sequence

Definition at line 1431 of file main.py.

◆ shell

main.shell

Concatenate all .avi files and move to parent folder.

Definition at line 225 of file main.py.

◆ shortcutCamera

main.shortcutCamera

Definition at line 1232 of file main.py.

◆ shortcutSequences

main.shortcutSequences

Definition at line 1232 of file main.py.

◆ showTrackingCompletion

main.showTrackingCompletion

Definition at line 889 of file main.py.

◆ site

main.site

Definition at line 1326 of file main.py.

◆ site_analyses

main.site_analyses

Definition at line 1114 of file main.py.

◆ site_analysis

main.site_analysis

Plot DMP stuff.

Prediction method preparation has to be completed for this step to work)

Definition at line 2231 of file main.py.

◆ siteIx

main.siteIx = sites.interpret(commands.site)[0]

Setup.

Support command-line video playback (called as a permanent interrupt)

Prepare data (load first sequence of each camera)

Get Metadata.

Prepare data.

Definition at line 209 of file main.py.

◆ siteIxs

main.siteIxs = sites.interpret(commands.site)

Loop through sites.

Definition at line 288 of file main.py.

◆ sites

main.sites = tvaScene.Sites(config)

Copy database and rebuild sites.

Handle mast location.

Definition at line 889 of file main.py.

◆ size

main.size

Definition at line 2016 of file main.py.

◆ skipTrajectoryContiguityCheck

main.skipTrajectoryContiguityCheck

Definition at line 1540 of file main.py.

◆ slsd

main.slsd

Definition at line 1832 of file main.py.

◆ smallestTTCVal

main.smallestTTCVal = sys.maxint

Definition at line 2003 of file main.py.

◆ soft_maxSpeed

main.soft_maxSpeed

Definition at line 1545 of file main.py.

◆ source

main.source

Load video stream.

Definition at line 310 of file main.py.

◆ speed_by_lane

main.speed_by_lane

Definition at line 1832 of file main.py.

◆ speed_histo

main.speed_histo = tvaCompute.computeSpeedHisto(objects.getSubSpacebyId(site_analyses[saIx].site.idx).getAll(), bins=np.arange(0,site_analyses[saIx].max_speed,1), framerate=sites[siteIx][camIx].camera.frameRate, verbose=commands.verbose)

Definition at line 1831 of file main.py.

◆ speed_histo_by_class

main.speed_histo_by_class = tvaCompute.computeSpeedHistoByClass(objects.getSubSpacebyId(site_analyses[saIx].site.idx).getAll(), user_class_variety=user_class_variety, bins=np.arange(0,site_analyses[saIx].max_speed,1), framerate=sites[siteIx][camIx].camera.frameRate, verbose=commands.verbose)

Definition at line 1834 of file main.py.

◆ speed_histo_by_lane

main.speed_histo_by_lane = tvaCompute.computeSpeedHistoByLane(objects.getSubSpacebyId(site_analyses[saIx].site.idx).getAll(), alignments=site_analyses[saIx].site.alignments, bins=np.arange(0,site_analyses[saIx].max_speed,1), framerate=sites[siteIx][camIx].camera.frameRate, verbose=commands.verbose)

Definition at line 1833 of file main.py.

◆ startTime

main.startTime

Definition at line 1441 of file main.py.

◆ style

main.style

Definition at line 2016 of file main.py.

◆ suppress_features

main.suppress_features

Definition at line 821 of file main.py.

◆ svmModels

main.svmModels = dict((svmModelName,TrafIntML_SVM()) for svmModelName in [config.class_PBV_SVMFilename,config.class_BV_SVMFilename,config.class_PB_SVMFilename,config.class_PV_SVMFilename])

Prepare HoG trained classifier.

Definition at line 452 of file main.py.

◆ tally

list main.tally = []

Administer tests.

Definition at line 456 of file main.py.

◆ temp

int main.temp = 0

Convert .mp4 files to .avi.

Definition at line 218 of file main.py.

◆ temp_dir

main.temp_dir

Delete any potentially pre-existing data in target scratch disk.

Remove any previously existing files.

Definition at line 599 of file main.py.

◆ this_run_endTime

main.this_run_endTime = max([y.getEndTime() for y in tvaLib.flatten_list([x.metadatas for x in objects.getSubSpacebyId(site_analyses[saIx].site.idx)])])

Definition at line 1785 of file main.py.

◆ this_run_startTime

main.this_run_startTime = min([y.getStartTime() for y in tvaLib.flatten_list([x.metadatas for x in objects.getSubSpacebyId(site_analyses[saIx].site.idx)])])

TODO: Function to stitch camera trajectories together here.

Check if successfully loaded data Misc

Definition at line 1784 of file main.py.

◆ threads

main.threads

Definition at line 608 of file main.py.

◆ timeHorizon

main.timeHorizon

Definition at line 1937 of file main.py.

◆ timeout

main.timeout

Definition at line 608 of file main.py.

◆ tracked_class

list main.tracked_class = [[x.getUserType() for x in seq_objects_src].count(i)/float(len(seq_objects_src)) for i in range(len(local['userTypeNames']))]

Definition at line 637 of file main.py.

◆ tracking_cases

main.tracking_cases = {}

Definition at line 587 of file main.py.

◆ trainingSamplesBV

main.trainingSamplesBV = dict((c,[]) for c in config.class_candidates)

Definition at line 383 of file main.py.

◆ trainingSamplesPB

main.trainingSamplesPB = dict((c,[]) for c in config.class_candidates)

Definition at line 384 of file main.py.

◆ trainingSamplesPBV

main.trainingSamplesPBV = dict((c,[]) for c in config.class_candidates)

Load images into memory and prepare HoGs.

Definition at line 382 of file main.py.

◆ trainingSamplesPV

main.trainingSamplesPV = dict((c,[]) for c in config.class_candidates)

Definition at line 385 of file main.py.

◆ trajectoryType

main.trajectoryType

Definition at line 1594 of file main.py.

◆ translationX

main.translationX

Definition at line 1291 of file main.py.

◆ translationY

main.translationY

Definition at line 1291 of file main.py.

◆ triage

main.triage

Definition at line 1937 of file main.py.

◆ True

main.True

Definition at line 1232 of file main.py.

◆ tsaiCameraSrcPath

main.tsaiCameraSrcPath = tvaLib.crawlDirsForFilePattern(pattern='*.tacal', path=os.getcwd(), returnList=False)

Attempt to import full camera calibration (.tacal), if it exists.

Definition at line 508 of file main.py.

◆ tvaHLI

main.tvaHLI = []

Load appropriate module(s)

Definition at line 1388 of file main.py.

◆ undistort_cmd_stack

main.undistort_cmd_stack

Definition at line 573 of file main.py.

◆ undistortedImageScalingFactor

main.undistortedImageScalingFactor

Definition at line 1440 of file main.py.

◆ unitsPerPixel

main.unitsPerPixel

Definition at line 511 of file main.py.

◆ usage_data

main.usage_data = dict((k, []) for k in usage_data_types)

Definition at line 1055 of file main.py.

◆ usage_data_other

list main.usage_data_other = []

Definition at line 1056 of file main.py.

◆ usage_data_types

dictionary main.usage_data_types
Initial value:
1 = {'video_extensions' : ['.mp4', '.mpg', '.avi', '.flv'],
2  'sequences' : ['.sqlite'],
3  'serialised_extensions' : ['.pva','.traj','.upairs'],
4  'analysis_image_extensions' : ['.png', '.pdf', '.jpg','.svg'],
5  'analysis_dump_extensions' : ['.csv','.xlsx'],
6  'text_extensions' : ['.txt','.log','.cfg']}

Loop through sequences.

Disk space usage

Definition at line 1047 of file main.py.

◆ user_class_variety

main.user_class_variety = tvaCompute.computeClassificationVariety(objects.getSubSpacebyId(site_analyses[saIx].site.idx).getAll(), verbose=commands.verbose)

Definition at line 1829 of file main.py.

◆ userPair

main.userPair = deepcopy(seq_userPairs)

Serialize data.

Cleanup data before pickling

Definition at line 1963 of file main.py.

◆ userPair_list

list main.userPair_list = userPairs[predictionMethod.idx].getAll()

For each prediction method...

TTC CSVs.

Definition at line 2157 of file main.py.

◆ userPairNums

main.userPairNums = list(userPair.roadUserNumbers)

Time Series Analysis.

Definition at line 1997 of file main.py.

◆ userPairs

list main.userPairs = [tvaScene.UPSpace(spaceType='sites') for x in predictionMethods]

Definition at line 1860 of file main.py.

◆ velocity_vector

main.velocity_vector

Definition at line 2017 of file main.py.

◆ verbose

main.verbose

Analysis.

Raised error handling or uncaught exception handling with PDB traceback.

Data analysis

Definition at line 272 of file main.py.

◆ version

main.version = 'R2.3.0 u. 2017-03-22'

Serialize/cache data.

Definition at line 5 of file main.py.

◆ video_out_fourcc

main.video_out_fourcc

Definition at line 275 of file main.py.

◆ view

main.view

Prepare tracking command stack.

Prepare base tracking command stack (before parameters)

Definition at line 569 of file main.py.

◆ VLTableHeadings1

list main.VLTableHeadings1 = []

Prepare headings Edges.

Definition at line 2249 of file main.py.

◆ VLTableHeadings2

list main.VLTableHeadings2 = []

Definition at line 2250 of file main.py.

◆ width

main.width = int(source.get(3))

Definition at line 314 of file main.py.

◆ worldPts

main.worldPts = None

Definition at line 509 of file main.py.

◆ writer

main.writer = csv_writer(f)

Output data.

Generic results CSV

Definition at line 2245 of file main.py.

◆ xy_bounds

main.xy_bounds

Definition at line 2017 of file main.py.

◆ zlabel

main.zlabel = local['vis_cp_label_prob']

For each pair of existing userTypes...

Generate human-readable label type Plot conflict points...

For each type of point... Generate human-readable label type

Definition at line 2195 of file main.py.

◆ zone

main.zone

Definition at line 616 of file main.py.