tvaLib
config.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # tvaLib Copyright (c) 2012-2016 Paul G. St-Aubin
3 # Ecole Polytechnique de Montreal, McGill University
4 # Python 2.7; (dt) Spyder Windows 10 64-bit; ipython Ubuntu 15.04 64-bit
5 
9 import os
10 from argparse import ArgumentParser
11 from ConfigParser import ConfigParser
12 from sys import platform
13 from tempfile import gettempdir
14 from collections import OrderedDict
15 
16 from lib.tools_parse import list1D as parse_list1D
17 from lib.tools_constructors import SuperList
18 
19 
22 class Config():
23  def __init__(self, readonly=False, filename='tva.cfg'):
24  self.filename=filename
25  self.config = ConfigParser()
26  self.config.read(filename)
27 
28  self.data = OrderedDict()
29  self.data['dir'] = ConfigValue('Main', default='', comment='Root directory where the video data and metadata database is stored and output will be written')
30  self.data['dbn'] = ConfigValue('Main', default='scene.sqlite', comment='Metadata database filename, typically scene.sqlite')
31  self.data['meta_db'] = ConfigValue('Main', default='meta_db.csv', comment='Optional metadata csv to accompany scene.sqlite')
32  self.data['path_to_trafint'] = ConfigValue('Main', default='', comment='Root path to Traffic-Intelligence')
33  self.data['autoflush_version'] = ConfigValue('Main', default=False, comment='Automatically flush cached data of an older version')
34  self.data['autoflush_ver_depth'] = ConfigValue('Main', default=3, comment='Version depth to determine data flushing')
35  self.data['debug'] = ConfigValue('Main', default=False, comment='Dev debugging mode')
36  self.data['language'] = ConfigValue('Main', default='en', comment='Plotting language, some interface elements also supported')
37  self.data['advanced_runtime'] = ConfigValue('Main', default=False, comment='Force runtime even if some dependencies couldn\'t be loaded')
38  self.data['s_proc_max_exec_time_in_s'] = ConfigValue('Main', default=300, comment='Maximum runtime of subprocesses')
39  self.data['readonly'] = ConfigValue('Main', default=False, comment='If set to True, this config will not be modified by the program')
40  self.data['disable_colour'] = ConfigValue('Main', default=False, comment='If set to True, coloured text mode will be forced to disabled')
41  self.data['output_folder'] = ConfigValue('Main', default='Analysis', comment='All output will be dumped in a folder with this name in the root directory')
42  self.data['calibration_folder'] = ConfigValue('Main', default='Calibration', comment='Calibration folder')
43  self.data['default_sequence_no'] = ConfigValue('Main', default=2, comment='This is the id of the sequence (in order, starting from 1) that will be used if no sequence is specified and if data must be collected from a single sequence.')
44  self.data['scratch_disk'] = ConfigValue('Main', default='tmp', comment='Path to a location/disk where temporary files will be stored. Leave as "tmp" to use the OS\'s default temporary directory.')
45  self.data['classification_method'] = ConfigValue('Main', default=0, comment='Classification method to be used. 0=speed, 1=hog')
46  self.data['alignmentOverride'] = ConfigValue('Main', default=False, comment='Set to true to override the check for alignment data completion.')
47 
48  self.data['interactive_max_col_size1'] = ConfigValue('Interface', default=20, comment='Interactive site selection column 1 width')
49  self.data['interactive_max_col_size2'] = ConfigValue('Interface', default=40, comment='Interactive site selection column 2 width')
50  self.data['interactive_max_col_size3'] = ConfigValue('Interface', default=60, comment='Interactive site selection column 3 width')
51 
52  self.data['MOT_max_distance'] = ConfigValue('MOT', default=10.0, comment='Maximum search distance for MOT')
53  self.data['MOT_max_generations'] = ConfigValue('MOT', default=0, comment='Maximum genetic algorithm generations to generate during optimization procedure')
54  self.data['MOT_population_size'] = ConfigValue('MOT', default=20, comment='Maximum genetic algorithm population size to simulate each generation')
55  self.data['MOT_end_criteria'] = ConfigValue('MOT', default=0.95, comment='MOT optimization will end after reaching this score')
56  self.data['MOT_save_all'] = ConfigValue('MOT', default=False, comment='MOT optimization will save all the files generated when set to True')
57  self.data['MOT_save_best'] = ConfigValue('MOT', default=False, comment='MOT optimization will save best file generated when set to True')
58  self.data['MOT_save_all_dir_name'] = ConfigValue('MOT', default='MOT_SavedFiles', comment='Directory where MOT analysis results (all) will be saved')
59 
60  self.data['video_out_fourcc'] = ConfigValue('VideoData', default='MJPG', comment='fourcc codec to use when recoding; e.g. MJPG or X264 http://www.fourcc.org/codecs.php')
61  self.data['mps_kmh'] = ConfigValue('VideoData', default=3.6, comment='I.e. 3.6. It is not recommended to change this')
62  self.data['max_speed'] = ConfigValue('VideoData', default=100, comment='Maximum possible observed speed assumed, in km/h')
63  self.data['timehorizon'] = ConfigValue('VideoData', default=10.0, comment='Maximum time in future to predict conflicts, in seconds')
64  self.data['loop_radius'] = ConfigValue('VideoData', default=3, comment='Radius size of virtual loops, in metres')
65  self.data['max_obj_features'] = ConfigValue('VideoData', default=400, comment='Maximum number of features to load per object (memory saving feature). HOG classification (method 1) performs better with more features.')
66  self.data['img_box_height_compensation'] = ConfigValue('VideoData', default=True, comment='If true, compensate the center of the image box, compensating for the parralax error of a trajectory due to height.')
67 
68  self.data['pred_minSampleSize'] = ConfigValue('DMP', default=10, comment='Minimum sample size to make a DMP motion prediction')
69  self.data['pred_probability_threshold'] = ConfigValue('DMP', default=0.00001, comment='Minimum prediction probability threshold for a motion pattern to be conserved')
70  self.data
71  self.data['up_maxUserPairsPerHour'] = ConfigValue('Conflicts', default=4000, comment='Maximum number of user pairs per hour to analyze (if there are more, user pairs will be subsampled evenly)')
72  self.data['up_maxDistance'] = ConfigValue('Conflicts', default=50.0, comment='Maximum distance between road users in order to consider them a pair')
73  self.data['col_probability_threshold'] = ConfigValue('Conflicts', default=0.001, comment='Minimum collision probability threshold for a conflict to be registered')
74 
75  self.data['monthly_expansion_factors'] = ConfigValue('Traffic Data', default=[0.083,0.083,0.083,0.083,0.083,0.083,0.083,0.083,0.083,0.083,0.083,0.083], c_struct='list1D', comment='')
76  self.data['doweek_expansion_factors'] = ConfigValue('Traffic Data', default=[0.1428,0.1428,0.1428,0.1428,0.1428,0.1428,0.1428], c_struct='list1D', comment='')
77  self.data['hourly_expansion_factors'] = ConfigValue('Traffic Data', default=[0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417,0.0417], c_struct='list1D', comment='')
78 
79  self.data['draw_max_traj'] = ConfigValue('Plotting', default=300, comment='Maximum trajectories to work with with visual tools')
80  self.data['plot_dropped_traj'] = ConfigValue('Plotting', default=False, comment='Plot trajectories that were dropped in a separate folder')
81  self.data['plot_text_size'] = ConfigValue('Plotting', default=16, comment='Size of text')
82  self.data['cm_colour'] = ConfigValue('Plotting', default='hot', comment='http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps\n')
83  self.data['speed_map_u_scale'] = ConfigValue('Plotting', default=50, comment='Upper speed limit to plot histograms to')
84  self.data['hex_grid_dimension'] = ConfigValue('Plotting', default=[60,60], c_struct='list1D', comment='Dimensions for hex grid')
85  self.data['hex_grid_min_size'] = ConfigValue('Plotting', default=1.0, comment='Minimum size of hex (in m) to use (overrides hex_grid_dimension as necessary)')
86  self.data['figsize'] = ConfigValue('Plotting', default=[15.0,12.0], c_struct='list1D', comment='Default figure size')
87  self.data['minVFcount'] = ConfigValue('Plotting', default=10, comment='Minimum vectors to draw vector field')
88  self.data['TTCthreshSeconds'] = ConfigValue('Plotting', default=1.5, comment='Maximum value of TTC for threshold TTC plotting, in seconds')
89  self.data['font_family'] = ConfigValue('Plotting', default='Arial', comment='Plotting font')
90  self.data['fig_bg_colour'] = ConfigValue('Plotting', default='#ffffff', comment='Plotting background (transparent if none)')
91 
92  self.data['disp_timehorizon'] = ConfigValue('Analysis', default=5.0, comment='Maximum time in future to compound conflict data, in seconds')
93 
94  self.data['corridorMinProximity'] = ConfigValue('Network', default=5.0, comment='')
95  self.data['corridorMinContDistance'] = ConfigValue('Network', default=20.0, comment='')
96  self.data['connectorSearchDistance'] = ConfigValue('Network', default=5.0, comment='')
97  self.data['intersectionDistanceFactor'] = ConfigValue('Network', default=3.0, comment='')
98 
99  self.data['f_bb_max_outside_dist'] = ConfigValue('Filter Params', default=2.0, comment='')
100  self.data['f_bb_containment_threshold'] = ConfigValue('Filter Params', default=0.96, comment='')
101  self.data['f_bb_loopback_ver_frames'] = ConfigValue('Filter Params', default=20, comment='')
102  self.data['f_so_hard_maxSpeed'] = ConfigValue('Filter Params', default=6.0, comment='')
103  self.data['f_so_soft_maxSpeed'] = ConfigValue('Filter Params', default=2.0, comment='')
104  self.data['f_so_max_angle'] = ConfigValue('Filter Params', default=45.0, comment='')
105  self.data['f_te_config_min_traj_len'] = ConfigValue('Filter Params', default=20, comment='')
106  self.data['f_td_min_sep_distance'] = ConfigValue('Filter Params', default=8.0, comment='')
107  self.data['f_td_min_sep_velocity'] = ConfigValue('Filter Params', default=8.0, comment='')
108  self.data['f_cl_align_window_m'] = ConfigValue('Filter Params', default=4.0, comment='')
109 
110  self.data['fs_search_window'] = ConfigValue('Filter_Stitch', default=50, comment='')
111  self.data['fs_max_dwell_time'] = ConfigValue('Filter_Stitch', default=0.66, comment='')
112  self.data['fs_speed_adj_factor'] = ConfigValue('Filter_Stitch', default=1000.0, comment='')
113  self.data['fs_speed_sim_limit_min'] = ConfigValue('Filter_Stitch', default=10, comment='')
114  self.data['fs_speed_similarity_lim'] = ConfigValue('Filter_Stitch', default=0.30, comment='')
115  self.data['fs_search_radius'] = ConfigValue('Filter_Stitch', default=8.0, comment='')
116  self.data['fs_stop_speed_det_lim'] = ConfigValue('Filter_Stitch', default=5.5, comment='')
117  self.data['fs_angle_similairty_deg'] = ConfigValue('Filter_Stitch', default=80.0, comment='')
118 
119  self.data['class_svmType'] = ConfigValue('HOGClassification',default=100, comment='')
120  self.data['class_kernelType'] = ConfigValue('HOGClassification',default=2, comment='')
121  self.data['class_degree'] = ConfigValue('HOGClassification',default=0, comment='')
122  self.data['class_gamma'] = ConfigValue('HOGClassification',default=1, comment='')
123  self.data['class_coef0'] = ConfigValue('HOGClassification',default=0, comment='')
124  self.data['class_cvalue'] = ConfigValue('HOGClassification',default=1, comment='')
125  self.data['class_nu'] = ConfigValue('HOGClassification',default=0, comment='')
126  self.data['class_svmP'] = ConfigValue('HOGClassification',default=0, comment='')
127  self.data['class_useAllSites'] = ConfigValue('HOGClassification',default=False, comment='')
128  self.data['class_min_n_features'] = ConfigValue('HOGClassification',default=10, comment='')
129  self.data['class_PBV_SVMFilename'] = ConfigValue('HOGClassification',default='modelPBV.xml', comment='filename of the general ped/cyc/veh SVM classifier')
130  self.data['class_BV_SVMFilename'] = ConfigValue('HOGClassification',default='modelBV.xml', comment='filename of the cyc/veh SVM classifier')
131  self.data['class_PV_SVMFilename'] = ConfigValue('HOGClassification',default='modelPV.xml', comment='filename of the cyc/veh SVM classifier')
132  self.data['class_PB_SVMFilename'] = ConfigValue('HOGClassification',default='modelPB.xml', comment='filename of the cyc/veh SVM classifier')
133  self.data['class_percentIncreaseCrop'] = ConfigValue('HOGClassification',default=0.2, comment='percent increase of the max of width and height of the bounding box of features extracted for classification')
134  self.data['class_minNPixels'] = ConfigValue('HOGClassification',default=800, comment='min number of pixels in cropped image to classify by SVM')
135  self.data['class_hogRescaleSize'] = ConfigValue('HOGClassification',default=[64,64], c_struct='list1D', comment='square size to resize image crops for HoG computation')
136  self.data['class_hogNOrientations'] = ConfigValue('HOGClassification',default=9, comment='number of HoG orientation')
137  self.data['class_hogNPixelsPerCell'] = ConfigValue('HOGClassification',default=[8,8], c_struct='list1D', comment='number of pixels per cell for HoG computation')
138  self.data['class_hogNCellsPerBlock'] = ConfigValue('HOGClassification',default=[2,2], c_struct='list1D', comment='number of cells per block for HoG computation')
139  self.data['class_hogBlockNorm'] = ConfigValue('HOGClassification',default='L1-sqrt', comment='block normalization method (L1, L1-sqrt, L2, L2-Hys)')
140  self.data['class_speedAggregationMeth'] = ConfigValue('HOGClassification',default='median', comment='method to aggregate road user speed')
141  self.data['class_nFramesIgnoreAtEnds'] = ConfigValue('HOGClassification',default=2, comment='number of frames to ignore at both ends of a series (noisy)')
142  self.data['class_speedAggregationQuant'] = ConfigValue('HOGClassification',default=50, comment='quantile for the speed aggregation, if quantile is chosen')
143  self.data['class_minSpeedEquiprobable'] = ConfigValue('HOGClassification',default=3.33, comment='speed value below which all classes are equiprobable (distributions give odd values there) (km/h)')
144  self.data['class_maxPercentUnknown'] = ConfigValue('HOGClassification',default=0.66, comment='maximum proportion of the instants with unknow appearance classification to use speed information')
145  self.data['class_maxPedestrianSpeed'] = ConfigValue('HOGClassification',default=10.0, comment='maximum pedestrian speed (agregate: mean, median, 85th centile, etc.) 10 km/h')
146  self.data['class_maxCyclistSpeed'] = ConfigValue('HOGClassification',default=30.0, comment='maximum cyclist speed (agregate: mean, median, 85th centile, etc.) 30 km/h (3xped)')
147  self.data['class_meanPedestrianSpeed'] = ConfigValue('HOGClassification',default=4.91, comment='mean pedestrian speed (in a normal distribution) km/h')
148  self.data['class_stdPedestrianSpeed'] = ConfigValue('HOGClassification',default=0.88, comment='standard deviation pedestrian speed (in a normal distribution) km/h')
149  self.data['class_meanCyclistSpeed'] = ConfigValue('HOGClassification',default=15.0, comment='mean pedestrian speed (in a normal distribution) km/h')
150  self.data['class_stdCyclistSpeed'] = ConfigValue('HOGClassification',default=5.0, comment='standard deviation pedestrian speed (in a normal distribution) km/h')
151  self.data['class_meanVehicleSpeed'] = ConfigValue('HOGClassification',default=30.00, comment='mean vehicle speed (in a normal distribution) km/h')
152  self.data['class_stdVehicleSpeed'] = ConfigValue('HOGClassification',default=7.6, comment='standard deviation vehicle speed (in a normal distribution) km/h')
153  self.data['class_locationCyclistSpeed'] = ConfigValue('HOGClassification',default=2.31, comment='to multiply the parameters by a, loc = loc+ln(a)')
154  self.data['class_scaleCyclistSpeed'] = ConfigValue('HOGClassification',default=0.42, comment='')
155  self.data['class_candidates'] = ConfigValue('HOGClassification',default=[1,2,4], c_struct='list1D', comment='The user type numbers to identify when classifying')
156 
157  self.data['event_label_1'] = ConfigValue('Event Labels' ,default='Event 1', comment='')
158  self.data['event_label_2'] = ConfigValue('Event Labels' ,default='Event 2', comment='')
159  self.data['event_label_3'] = ConfigValue('Event Labels' ,default='Event 3', comment='')
160  self.data['event_label_4'] = ConfigValue('Event Labels' ,default='Event 4', comment='')
161  self.data['event_label_5'] = ConfigValue('Event Labels' ,default='Event 5', comment='')
162  self.data['event_label_6'] = ConfigValue('Event Labels' ,default='', comment='')
163  self.data['event_label_7'] = ConfigValue('Event Labels' ,default='', comment='')
164  self.data['event_label_8'] = ConfigValue('Event Labels' ,default='', comment='')
165  self.data['event_label_9'] = ConfigValue('Event Labels' ,default='', comment='')
166  self.data['event_label_10'] = ConfigValue('Event Labels' ,default='', comment='')
167 
168  self.prepare()
169  updateNeeded = self.checkAutoUpdate()
170  self.parse()
171  if(updateNeeded): self.write()
172 
173 
174  if(self.scratch_disk == 'tmp'): self.temp_dir = gettempdir()
175  else: self.temp_dir = self.scratch_disk
176  if(not readonly and not self.readonly and not os.path.isfile(self.filename)):
177  print('Notice: No default configuration found. Creating new '+self.filename)
178  self.write()
179  self.event_labels = [x for x in [self.event_label_1,self.event_label_2,self.event_label_3,self.event_label_4,self.event_label_5,self.event_label_6,self.event_label_7,self.event_label_8,self.event_label_9,self.event_label_10] if x]
180 
181  def __dir__(self): return self.data.keys()
182  def __repr__(self): return '<tvaLib configuration settings>'
183  def __str__(self): return 'tvaLib configuration settings'
184  def __nonzero__(self): return True
185  def __getattr__(self, key):
186  try: return self.data[key].value
187  except KeyError: raise AttributeError, key
188  def getMethod(self, key): return self.data[key]
189  def setValue(self, key, value): self.data[key].setValue(value)
190 
191  def prepare(self):
192  for name in self.data: self.data[name].name = name
193  def parse(self):
194  for name in self.data: self.data[name].parse(parser=self.config)
195  def checkAutoUpdate(self):
196  for name in self.data:
197  if(not self.config.has_option(self.data[name].section,name)): return True
198  return False
199 
200  def write(self, justifyCols=[30,50]):
201  with open(self.filename, 'w') as configfile:
202  for section in set([self.data[name].section for name in self.data]):
203  configfile.write('['+section+']\n')
204  for name in self.data:
205  if(self.data[name].section == section): configfile.write(name.ljust(justifyCols[0])+' = '+str(self.data[name].value).ljust(justifyCols[1])+' ; '+str(self.data[name].comment)+'\n')
206  configfile.write('\n')
207 
208 class ConfigValue():
209  def __init__(self, section='section', name='name', default=None, value=None, c_struct='simple', comment=''):
210  self.section = section
211  self.name = name
212  self.value = value
213  self.default = default
214  self.comment = comment
215  self.c_struct = c_struct
216  if(self.c_struct=='list1D'): self.c_type = type(default[0])
217  else: self.c_type = type(default)
218 
219  def setValue(self, value): self.value = value
220 
221  def parse(self, parser):
222  ''' Load configuration file values. '''
223  if(not parser.has_section(self.section)): parser.add_section(self.section)
224  if(not parser.has_option(self.section,self.name)): parser.set(self.section,self.name,str(self.default))
225  try:
226  if(self.c_type == int):
227  if(self.c_struct == 'list1D'): self.value = parse_list1D(parser.get(self.section, self.name))
228  else: self.value = parser.getint(self.section, self.name)
229  elif(self.c_type == float):
230  if(self.c_struct == 'list1D'): self.value = parse_list1D(parser.get(self.section, self.name), i_type='float')
231  else: self.value = parser.getfloat(self.section, self.name)
232  elif(self.c_type == bool):
233  if(self.c_struct == 'list1D'): self.value = parse_list1D(parser.get(self.section, self.name), i_type='bool')
234  else: self.value = parser.getboolean(self.section, self.name)
235  else:
236  if(self.c_struct == 'list1D'): self.value = parse_list1D(parser.get(self.section, self.name), i_type='string')
237  else: self.value = parser.get(self.section, self.name)
238  except ValueError: raise Exception, [1001, 'Invalid value in configuration for parameter "'+self.name+'"']
239  except TypeError: import pdb; pdb.set_trace()
240  return True
241 
242 
243 
244 
247 def commands():
248  parser = ArgumentParser()
249 
250 
251  parser.add_argument('opt1', nargs='?')
252  parser.add_argument('opt2', nargs='?')
253  parser.add_argument('opt3', nargs='?')
254 
255 
256  parser.add_argument( '--concat', action='store_true', dest='concat', default=False, help='[bool] Run batch analysis on all sequences only (does not pre-treat sequences individually; assumes already pre-treated)')
257  parser.add_argument( '--skip-concat', action='store_true', dest='skip_concat', default=False, help='[bool] If concat is set to False, setting this to true will force concat mode to be skipped completly)')
258  parser.add_argument( '--multicore', action='store_true', dest='multicore', default=False, help='[bool] If set to true, and running multiple threads, a single child process will be spawned but this child will consume all normally available threads.')
259  parser.add_argument( '--configreadonly', action='store_true', dest='configreadonly', default=False, help='[bool] If set to true, configuration file will be be run in read-only mode (this corrects an issue with multiprocessing race conditions).')
260  parser.add_argument( '--oneseqpersite', action='store_true', dest='oneseqpersite', default=False, help='[bool] If set to true, only one sequence will be processed per site or site-analysis.')
261 
262 
263  parser.add_argument( '--cluster', type=str, dest='cluster', default='', help='[str] (A) Specify cluster of analyses by name. An empty string will process all clusters.')
264  parser.add_argument( '--export-csv', action='store_true', dest='export_csv', default=False, help='[bool] (A) Dump data to csv files.')
265  parser.add_argument( '--depth', type=int, dest='depth', default=2, help='[int] (A) Specify depth of analysis.')
266 
267 
268  parser.add_argument( '--create-camtype', action='store_true', dest='create_camtype', default=False, help='[bool] Create metadata element: camera type')
269  parser.add_argument( '--create-site', action='store_true', dest='create_site', default=False, help='[bool] Create metadata element: site')
270  parser.add_argument( '--create-view', action='store_true', dest='create_view', default=False, help='[bool] Create metadata element: camera view')
271  parser.add_argument( '--create-seqs', action='store_true', dest='create_seqs', default=False, help='[bool] Create metadata elements: sequences')
272  parser.add_argument( '--create-sa', action='store_true', dest='create_sa', default=False, help='[bool] Create metadata element: site-analysis')
273  parser.add_argument( '--create-analysis', action='store_true', dest='create_analysis', default=False, help='[bool] Create metadata element: analysis')
274 
275 
276  parser.add_argument( '--undistort', action='store_true', dest='undistort', default=False, help='[bool] Run undistortion functions')
277  parser.add_argument( '--framedump', action='store_true', dest='framedump', default=False, help='[bool] Force a frame dump of the selected sequence')
278  parser.add_argument( '--train-class', action='store_true', dest='train_classifier', default=False, help='[bool] Train classification algorythm')
279  parser.add_argument( '--test-class', action='store_true', dest='test_classifier', default=False, help='[bool] Test the trained classification algorythm')
280  parser.add_argument( '--extract-images', action='store_true', dest='extract_images', default=False, help='[bool] Use this option to extract images from selected sites')
281  parser.add_argument( '--homo', type=int, dest='homo', default=0, help='[int] Run homography functions with this many points')
282  parser.add_argument( '--homosatsrc', type=str, dest='homo_sat_src', default='', help='[str] Force loading a specific satellite image file by filename')
283  parser.add_argument( '--test-track', action='store_true', dest='test_track', default=False, help='[bool] Run tracking sequence test. Combine with -r for visual inspection.')
284  parser.add_argument( '--test-track-params', type=str, dest='test_track_param_filename', default='', help='[str] Path to file with tracking parameters to test. File should be a csv, one colum per param, with first line being the param name, and each subsequent line being one tast case.')
285  parser.add_argument( '--trafint', action='store_true', dest='trafint', default=False, help='[bool] Run trajectory extraction functions')
286  parser.add_argument( '--mota-opt-t', action='store_true', dest='mota_opt_t', default=False, help='[bool] Attempt an MOT optimisation (tracking and grouping parameters)')
287  parser.add_argument( '--mota-opt-g', action='store_true', dest='mota_opt_g', default=False, help='[bool] Attempt an MOT optimisation (grouping parameters)')
288  parser.add_argument( '--mota-opt-f', action='store_true', dest='mota_opt_f', default=False, help='[bool] Attempt an MOT optimisation (filtering parameters)')
289  parser.add_argument( '--del-tva', action='store_true', dest='detroy_tva_data', default=False, help='[bool] This destroys related saved tvaLib data (ALL data including, serialisation, events, results, figures), except for analysis output')
290  parser.add_argument( '--del-tva-traj', action='store_true', dest='detroy_tva_data_ser_traj', default=False, help='[bool] This destroys related saved tvaLib data (serialisation only)')
291  parser.add_argument( '--del-tidata', action='store_true', dest='detroy_ti_data', default=False, help='[bool] This destroys related TI tracking data')
292  parser.add_argument( '--del-fig-by-type', type=str, dest='detroy_figures_by_type', default='', help='[str] Flushes any saved figures of this specific type (by file extension)')
293  parser.add_argument( '--disk-space-usage', action='store_true', dest='disk_space_usage', default=False, help='[bool] Calculate disk space usage')
294  parser.add_argument( '--rfs', action='store_true', dest='rebuild_file_structure', default=False, help='[bool] Rebuild file structure (from root directory)')
295  parser.add_argument( '--rfs-from-disk', type=str, dest='rfs_from_disk', default='', help='[bool] Rebuild file structure (from root directory) copying metadata files from a source location')
296 
297 
298  parser.add_argument('-z', '--dir', type=str, dest='dir', default='', help='[str] Directory containing a specific database (overrides config)')
299  parser.add_argument('-d', '--dbn', type=str, dest='dbn', default='', help='[str] Load a specific database (overrides config)')
300  parser.add_argument( '--analysis', type=str, dest='analysis', default='', help='[str] Load specific analysis case')
301  parser.add_argument('-b', '--s-analysis', type=str, dest='s_analysis', default='', help='[str] Load specific site analysis case')
302  parser.add_argument('-s', '--site', type=str, dest='site', default='', help='[str] Load specific site')
303  parser.add_argument('-c', '--camera', type=str, dest='camera', default='', help='[str] Load specific camera')
304  parser.add_argument('-f', '--file', type=str, dest='file', default='', help='[str] Load specific sequence')
305  parser.add_argument( '--filename-override', type=str, dest='filename_override', default='', help='[str] Temporarily force a sequence to use this specific tracking file instead')
306  parser.add_argument('-k', '--no-track-filt', action='store_true', dest='no_track_filt', default=False, help='[bool] Disable filtering functions correcting tracking errors.')
307  parser.add_argument( '--force-reclassify', action='store_true', dest='force_reclassify', default=False, help='[bool] Force relcassification of tracked objects.')
308  parser.add_argument( '--commit-classify', action='store_true', dest='commit_classify', default=False, help='[bool] Commit classifications back to SQLite file for future use.')
309  parser.add_argument( '--no-filt', action='store_true', dest='no_filt', default=False, help='[bool] Disable ALL filtering functions (advanced usage only)')
310  parser.add_argument( '--proc-gt', action='store_true', dest='proc_gt', default=False, help='[bool] Process ground truth trajectories if available. Filters will be disabled.')
311  parser.add_argument( '--rej-s', type=str, dest='rej_site', default='', help='[str] Reject specific sites')
312  parser.add_argument( '--rej-c', type=str, dest='rej_cam', default='', help='[str] Reject specific camera')
313  parser.add_argument('-p', '--play', action='store_true', dest='play', default=False, help='[bool] Launch interactive object inspector or playback video during TI operations')
314  parser.add_argument( '--play-vid', action='store_true', dest='play_vid', default=False, help='[bool] Launch interactive video playback.')
315  parser.add_argument( '--play-filt', type=str, dest='play_filt', default='', help='[str] Launch interactive filtered object inspector, by designated type, e.g.: ie, bb, so, te, td, tc')
316  parser.add_argument( '--play-inf', action='store_true', dest='play_inf', default=False, help='[bool] Play video of infractions')
317  parser.add_argument( '--play-int', action='store_true', dest='play_int', default=False, help='[bool] Launch interactive interaction inspector')
318  parser.add_argument( '--annotate', action='store_true', dest='annotate', default=False, help='[bool] Launch interactive annotation tool.')
319  parser.add_argument('-w', '--fig', action='store_true', dest='fig_save', default=False, help='[bool] Generate figures')
320  parser.add_argument( '--fig-advanced', action='store_true', dest='fig_save_advanced', default=False, help='[bool] Generate advanced figures. These are very slow to generate or are experimental.')
321  parser.add_argument( '--figure-save-lan-a', action='store_true', dest='fig_save_lan_a', default=False, help='[bool] When saving figures, append language as suffix')
322  parser.add_argument( '--figure-format', type=str, dest='fig_format', default='png', help='[str] Force saving images to a particular format. Enter a supported extensions (e.g. png, svg, pdf). Default is .png')
323  parser.add_argument( '--figure-resize', type=float, dest='fig_resize', nargs=2, default=None, help='[float]Force figure resize upon saving, in inches. Format is newX.float newY.float. Print freindly size: "10 7". Default is set in config.')
324  parser.add_argument( '--figure-style', type=str, dest='fig_style', default='', help='[str] Load a matplotlib style by name. recommend "bmh". See plotSettings() for more info')
325  parser.add_argument('-a', '--save-data', action='store_true', dest='save_data', default=False, help='[bool] Saves raw operational data')
326  parser.add_argument( '--save-data-light', action='store_true', dest='save_data_light', default=False, help='[bool] Saves only essential raw operational data')
327  parser.add_argument('-x', '--export', action='store_true', dest='export_traj', default=False, help='[bool] Export trajectories')
328  parser.add_argument('-u', '--flush', action='store_true', dest='save_data_flush', default=False, help='[bool] Flushes any saved data')
329  parser.add_argument( '--flush-objects', action='store_true', dest='save_data_flush_objects', default=False, help='[bool] Flushes any saved objects only')
330  parser.add_argument( '--flush-indicators', action='store_true', dest='save_data_flush_indicators', default=False, help='[bool] Flushes any saved indicators only')
331  parser.add_argument( '--flush-dmp', action='store_true', dest='save_data_flush_dmp', default=False, help='[bool] Flushes any saved DMP data')
332  parser.add_argument( '--gen-dmp', action='store_true', dest='save_data_gen_dmp', default=False, help='[bool] In this mode, only DMP data will be generated, interactions will be skipped')
333  parser.add_argument( '--plot-dmp', action='store_true', dest='plot_dmp', default=False, help='[bool] Produce sample DMP plot')
334  parser.add_argument('-q', '--statistics', action='store_true', dest='stat', default=False, help='[bool] Dump statistics')
335  parser.add_argument( '--sample-traj', type=str, dest='sample_traj', default='', help='[str(int,list)] Declare to plot individual trajectory points (pre-filter)')
336  parser.add_argument('-r', '--draw', action='store_true', dest='draw', default=False, help='[bool] Run in basic draw mode')
337  parser.add_argument( '--draw-align', action='store_true', dest='draw_align', default=False, help='[bool] Run in draw mode (alignments)')
338  parser.add_argument( '--draw-align-no-trk', action='store_true', dest='draw_align_no_trk', default=False, help='[bool] Run in draw mode (alignments; without loading trajectories)')
339  parser.add_argument( '--draw-mask', action='store_true', dest='draw_mask', default=False, help='[bool] Run in draw mode (image mask)')
340  parser.add_argument( '--draw-mask2', action='store_true', dest='draw_mask2', default=False, help='[bool] Run in draw mode (image mask, option/view 2)')
341  parser.add_argument( '--draw-zone', action='store_true', dest='draw_zone', default=False, help='[bool] Run in draw mode (analysis zone)')
342  parser.add_argument( '--draw-loops', action='store_true', dest='draw_loops', default=False, help='[bool] Run in draw mode (loop detectors)')
343  parser.add_argument( '--draw-transform', action='store_true', dest='draw_transform', default=False, help='[bool] Run in draw mode (transform coordinates)')
344  parser.add_argument( '--draw-mhc', action='store_true', dest='mast_height_calibration', default=False, help='[bool] Run in draw mode (mast height calibration)')
345  parser.add_argument( '--draw-ml', action='store_true', dest='draw_mast_location', default=False, help='[bool] Run in draw mode (mast location)')
346  parser.add_argument( '--draw-hli', action='store_true', dest='draw_hli', default=False, help='[bool] If running an HLI module, special drawing console will be run')
347  parser.add_argument( '--draw-bounds', action='store_true', dest='draw_bounds', default=False, help='[bool] Run in draw mode (plotting bounds)')
348  parser.add_argument( '--auto-bounds', action='store_true', dest='auto_bounds', default=False, help='[bool] Automatically create bounds for sites missing bounds.')
349  parser.add_argument('-g', '--snap-align', action='store_true', dest='snap_align', default=False, help='[bool] Choose points to get alignment information')
350  parser.add_argument('-j', '--obj-highlight', action='store_true', dest='obj_highlight', default=False, help='[bool] Highlight specific object trajectories (interactively)')
351  parser.add_argument('-o', '--objects', type=int, dest='max_obj', default=-1, help='[int] Load a desired number of objects (-1 for all)')
352  parser.add_argument( '--start-time', type=int, dest='start_time', default=0, help='[int] Start at a desired time (in seconds)')
353  parser.add_argument( '--time', type=int, dest='time', default=0, help='[int] Load a desired duration of time (in seconds, 0 for all)')
354  parser.add_argument('-t', '--threads', type=int, dest='threads', default=1, help='[int] Multi-core where possible with this many threads')
355  parser.add_argument('-i', '--indicators', type=str, dest='indicators', default='', help='[str(int,list)] 1D list of PredictionParameters to use; default = [0]; or turn off conflict analysis with -i []')
356  parser.add_argument( '--concat-data', action='store_true', dest='concat_mode', default=False, help='[bool] This mode wil concatenate result chunks into one result')
357  parser.add_argument('-l', '--log', action='store_true', dest='logging', default=False, help='[bool] Dump output to log.')
358  parser.add_argument('-v', '--verbose', type=int, dest='verbose', default=1, help='[int] Level of detail of results')
359  parser.add_argument( '--suppress-features', action='store_true', dest='suppress_features', default=False, help='[bool] Use this to suppress loading of features (not recommended for inexperienced users)')
360  parser.add_argument( '--mem-clean-feature', action='store_true', dest='memory_clean_feature', default=False, help='[bool] Purge features as soon as possible to save memory (recommended to use if running into memory issues with particularly large trajectory data sets)')
361  parser.add_argument( '--stitch', action='store_true', dest='stitch', default=False, help='[bool] Enable trajectory stitching between multiple cameras (currently unsupported)')
362  parser.add_argument('-e', '--interactive', action='store_true', dest='interactive', default=False, help='[bool] Toggle interactive selection mode')
363  parser.add_argument( '--interactive-opt', action='store_true', dest='interactive_opt', default=False, help='[bool] Toggle interactive commands')
364  parser.add_argument('-y', '--hli', type=str, dest='hli', default='', help='[str] Load high-level analysis module of this name')
365  parser.add_argument( '--hli-only', action='store_true', dest='hli_only', default=False, help='[bool] Skip normal analysis and process HLI only')
366  parser.add_argument( '--hli-report', action='store_true', dest='hli_report', default=False, help='[bool] Generate an automated report using an HLI extension if available. Check the extension\'s documentation to see if it expects additional/specific commands to be used for proper formatting')
367  parser.add_argument('-m', '--mot', action='store_true', dest='mot', default=False, help='[bool] Perform MOT (external dependency) ground truth analysis on objects after filtering')
368  parser.add_argument('-n', '--lan', type=str, dest='language', default='', help='[str] Specify output language (defaults to that specified in config file)')
369  parser.add_argument( '--legacy', action='store_true', dest='legacy', default=False, help='[bool] This command can be used to force legacy modes (for advanced users only)')
370  parser.add_argument( '--timeseries', type=int, dest='timeseries', nargs=2, default=False, help='[int] Enable timeseries analysis between these two objects')
371  parser.add_argument( '--infractions', action='store_true', dest='infractions', default=False, help='[bool] Enable infraction detection (experimental)')
372  parser.add_argument( '--max-ucon-obj', type=int, dest='max_ucon_obj', default=150, help='[int] Maximum number of unconstrained objects to store in memory automatically for plotting purposes (set to 0 to save memory.)')
373 
374 
375  commands = parser.parse_args()
376 
377 
378  if(commands.interactive_opt):
379  inp = raw_input('Interactive command mode elected. Enter some command line arguments\nnow to override defaults: ')
380  import shlex
381  try: commands = parser.parse_args(shlex.split(inp))
382  except: print 'Warning: Commands failed. Ignoring user input.'
383 
384 
385  if(commands.play or
386  commands.play_vid or
387  commands.play_filt or
388  commands.play_inf or
389  commands.play_int or
390  commands.annotate): commands.f_tk_interface = True
391  else: commands.f_tk_interface = False
392  if(commands.draw):
393  commands.draw_mask = True
394  commands.draw_align = True
395  commands.draw_zone = True
396  commands.draw_bounds = True
397  if(commands.homo or
398  commands.test_track or
399  commands.draw_align or
400  commands.draw_align_no_trk or
401  commands.draw_mask or
402  commands.draw_zone or
403  commands.draw_loops or
404  commands.draw_transform or
405  commands.draw_bounds or
406  commands.snap_align or
407  commands.obj_highlight or
408  commands.draw_hli or
409  commands.mast_height_calibration): commands.f_interface = True
410  else: commands.f_interface = False
411  if(commands.save_data_gen_dmp or
412  commands.plot_dmp or
413  commands.indicators):
414  commands.max_ucon_obj = None
415  commands.memory_clean_feature = True
416 
417 
426 
427  return commands
428 
429 
433  def __init__(self, **kwargs):
434  import prediction as TrafIntPrediction
435  import lib.prediction_DMP as tvaPrediction
436  self.data = [PredictionMethod(label='Constant Velocity', label_short='cvl', idx=0, paramClass=TrafIntPrediction.ConstantPredictionParameters, **kwargs),
437  PredictionMethod(label='Normal Adaptation', label_short='nad', idx=1, paramClass=TrafIntPrediction.NormalAdaptationPredictionParameters, **kwargs),
438  PredictionMethod(label='Point Set Prediction', label_short='psp', idx=2, paramClass=TrafIntPrediction.PointSetPredictionParameters, **kwargs),
439  PredictionMethod(label='Evasive Action', label_short='eva', idx=3, paramClass=TrafIntPrediction.EvasiveActionPredictionParameters, useFeatures=False, nPredictedTrajectories=100, maxAcceleration=4.3, **kwargs),
440  PredictionMethod(label='Feature Evasive Action', label_short='fea', idx=4, paramClass=TrafIntPrediction.EvasiveActionPredictionParameters, useFeatures=True, nPredictedTrajectories=10, maxAcceleration=4.3, **kwargs),
441  PredictionMethod(label='Curvilinear Motion Pattern', label_short='cmp', idx=5, paramClass=tvaPrediction.MotionPattern, protocol='dmp', prepare=True, **kwargs)]
442 
443  def setCameraSettings(self, **kwargs):
444  for data in self.data:
445  data.setCameraSettings(**kwargs)
446  return True
447 
449  def __init__(self, label, label_short, idx, paramClass, protocol='ccc', prepare=False, **kwargs):
450  self.label = label
451  self.label_short = label_short
452  self.idx = idx
453  self.paramClass = paramClass
454  self.protocol = protocol
455  self.prepare_ = prepare
456  self.params = PredictionParams(protocol=self.protocol, **kwargs)
457  self.predictionClass = None
458 
459  def setCameraSettings(self, **kwargs): return self.params.setCameraSettings(**kwargs)
460  def setAccelerationDistribution(self, value): self.params.setAccelerationDistribution(value)
461  def setSteeringDistribution(self, value): self.params.setSteeringDistribution(value)
462 
463  def getPrepare(self): return self.prepare_
464 
466  if(self.predictionClass is not None): return self.predictionClass
467  return self.paramClass(**self.stripKwargsForUncleanTarget(self.params.getParamDict()))
468 
469  def storePredictionClass(self): self.predictionClass = self.getPredictionClass()
470 
471  def prepare(self, *args):
472  if(self.predictionClass is None): self.storePredictionClass()
473  return self.predictionClass.prepare(*args, **self.params.getParamDict())
474 
475  def export(self, path=''):
476  if(self.predictionClass is not None): return self.predictionClass.export(path=path, **self.params.getParamDict())
477  return False
478 
479  def stripKwargsForUncleanTarget(self, kwargs):
480  if(len(kwargs) <= 0): return {}
481  from inspect import getargspec as inspect_getargspec
482  args = inspect_getargspec(self.paramClass.__init__)
483  for kwarg in kwargs:
484  if(not kwarg in args.args):
485  kwargs[kwarg] = None
486  return dict((k, v) for k, v in kwargs.iteritems() if v)
487 
488 
490  def __init__(self, protocol='ccc', maxSpeed=50, nPredictedTrajectories=3, minAcceleration=-2.0, maxAcceleration=2.0, maxSteering=0.2, useFeatures=False, mps_to_kmh=3.6, timeHorizon=1.5, speedBinNum=7, curvilinearBinSize=3, motPatBinNum=40, minSampleSize=50, probRetentionThreshold=0.00001, motPatBinSize=[1,1], xy_bounds=None, allowImport=True, importLocations='', customSpeedRange=None, results_path='', verbose=0, version=''):
491  self.protocol = protocol
492  self.framerate = 15.0
493  self.mps_to_kmh = 3.6
494  self.maxSpeed = maxSpeed
495  self.nPredictedTrajectories = nPredictedTrajectories
496  self.minAcceleration = minAcceleration
497  self.maxAcceleration = maxAcceleration
498  self.maxSteering = maxSteering
499  self.useFeatures = useFeatures
502 
503  self.minSampleSize = minSampleSize
504  self.probRetentionThreshold = probRetentionThreshold
505  self.alignments = None
506  self.timeHorizon = timeHorizon
507  self.speedBinNum = speedBinNum
508  self.curvilinearBinSize = curvilinearBinSize
509  self.motPatBinNum = motPatBinNum
510  self.motPatBinSize = motPatBinSize
511  self.xy_bounds = xy_bounds
512  self.allowImport = allowImport
513  self.importLocations = importLocations
514  self.customSpeedRange = customSpeedRange
515  self.results_path = results_path
516  self.verbose = verbose
517  self.version = version
518 
519  def setCameraSettings(self, framerate=15.0, alignments=None):
520  self.framerate = float(framerate)
521  self.alignments = alignments
522  return True
523  def setAccelerationDistribution(self, value): self.accelerationDistribution = value
524  def setSteeringDistribution(self, value): self.steeringDistribution = value
525 
526  def getMaxSpeed(self): return self.maxSpeed
527  def getNPredictedTrajectories(self): return self.nPredictedTrajectories
528  def getMinAcceleration(self): return self.minAcceleration/self.framerate**2
529  def getMaxAcceleration(self): return self.maxAcceleration/self.framerate**2
530  def getMaxSteering(self): return self.maxSteering/self.framerate
531  def getUseFeatures(self): return self.useFeatures
532  def getAccelerationDistribution(self): return self.accelerationDistribution
533  def getSteeringDistribution(self): return self.steeringDistribution
534 
535  def getMinSampleSize(self): return self.minSampleSize
536  def getProbRetentionThreshold(self): return self.probRetentionThreshold
537  def getAlignments(self): return self.alignments
538  def getSpeed_conv(self): return self.framerate*self.mps_to_kmh
539  def getTimeHorizon(self): return int(self.timeHorizon*self.framerate)
540  def getSpeedBinNum(self): return self.speedBinNum
541  def getCurvilinearBinSize(self): return self.curvilinearBinSize
542  def getMotPatBinNum(self): return self.motPatBinNum
543  def getMotPatBinSize(self): return self.motPatBinSize
544  def getXy_bounds(self): return self.xy_bounds
545  def getAllowImport(self): return self.allowImport
546  def getImportLocations(self): return self.importLocations
547  def getCustomSpeedRange(self): return self.customSpeedRange
548  def getResults_path(self): return self.results_path
549  def getVerbose(self): return self.verbose
550  def getVersion(self): return self.version
551 
552 
553  def getParamDict(self):
554  if(self.protocol=='ccc'): return {'maxSpeed': self.getMaxSpeed(),
555  'nPredictedTrajectories': self.getNPredictedTrajectories(),
556  'minAcceleration': self.getMinAcceleration(),
557  'maxAcceleration': self.getMaxAcceleration(),
558  'maxSteering': self.getMaxSteering(),
559  'useFeatures': self.getUseFeatures(),
560  'accelerationDistribution': self.getAccelerationDistribution(),
561  'steeringDistribution': self.getSteeringDistribution()}
562  else: return {'minSampleSize': self.getMinSampleSize(),
563  'probRetentionThreshold': self.getProbRetentionThreshold(),
564  'maxSpeed': self.getMaxSpeed(),
565  'alignments': self.getAlignments(),
566  'speed_conv': self.getSpeed_conv(),
567  'timeHorizon': self.getTimeHorizon(),
568  'speedBinNum': self.getSpeedBinNum(),
569  'curvilinearBinSize': self.getCurvilinearBinSize(),
570  'motPatBinNum': self.getMotPatBinNum(),
571  'motPatBinSize': self.getMotPatBinSize(),
572  'xy_bounds': self.getXy_bounds(),
573  'allowImport': self.getAllowImport(),
574  'importLocations': self.getImportLocations(),
575  'customSpeedRange': self.getCustomSpeedRange(),
576  'results_path': self.getResults_path(),
577  'verbose': self.getVerbose(),
578  'version': self.getVersion()}
579 
580  def cleanUp(self):
581  self.accelerationDistribution = None
582  self.steeringDistribution = None
583 
585  def __init__(self, **kwargs):
586  self.data = [AggMethod('all', 'all'),
587  AggMethod('unique 15th', '15t', method=1, percentile=0.15),
588  AggMethod('unique min', 'min', method=1),
589  AggMethod('unique max prob', 'maxProb', method=3, percentile=0.85)]
590 
591 class AggMethod():
592  def __init__(self, label='', label_short='', method=0, percentile=0.0):
593  ''' Methods:
594  ========
595  0 = all indicators
596  1 = percentile indicator
597  3 = percentile prob
598  '''
599  self.label = label
600  self.label_short = label_short
601  self.method = method
602  self.percentile = percentile
603 
604 
606  def __init__(self, **kwargs):
607  self.data = [InteractionClassificationMethod('head-on', 'head', incidenceAngleRanges=[[150,210]]),
608  InteractionClassificationMethod('side-swipe', 'side', incidenceAngleRanges=[[30,150],[210,270]]),
609  InteractionClassificationMethod('rear-end', 'rear', incidenceAngleRanges=[[0,30],[270,360]])]
610 
612  def __init__(self, label='', label_short='', incidenceAngleRanges=[[0,360]]):
613  self.label = label
614  self.label_short = label_short
615  self.incidenceAngleRanges = incidenceAngleRanges
616 
617 
620 class Fore(object):
621  ''' Override ANSI colour classes if colorama is not installed. '''
622  def __init__(self, forceOff=False):
623  if(platform == 'win32' or forceOff): self.disable()
624  else: self.enable()
625  def disable(self):
626  self.BLACK = ''
627  self.RED = ''
628  self.GREEN = ''
629  self.YELLOW = ''
630  self.BLUE = ''
631  self.MAGENTA = ''
632  self.CYAN = ''
633  self.WHITE = ''
634  self.RESET = ''
635  def enable(self):
636  self.BLACK = '\033[30m'
637  self.RED = '\033[31m'
638  self.GREEN = '\033[32m'
639  self.YELLOW = '\033[33m'
640  self.BLUE = '\033[34m'
641  self.MAGENTA = '\033[35m'
642  self.CYAN = '\033[36m'
643  self.WHITE = '\033[37m'
644  self.RESET = '\033[39m'
645 
646 class Back(object):
647  ''' Override ANSI colour classes if colorama is not installed. '''
648  def __init__(self, forceOff=False):
649  if(platform == 'win32' or forceOff): self.disable()
650  else: self.enable()
651  def disable(self):
652  self.BLACK = ''
653  self.RED = ''
654  self.GREEN = ''
655  self.YELLOW = ''
656  self.BLUE = ''
657  self.MAGENTA = ''
658  self.CYAN = ''
659  self.WHITE = ''
660  self.RESET = ''
661  def enable(self):
662  self.BLACK = '\033[40m'
663  self.RED = '\033[41m'
664  self.GREEN = '\033[42m'
665  self.YELLOW = '\033[43m'
666  self.BLUE = '\033[44m'
667  self.MAGENTA = '\033[45m'
668  self.CYAN = '\033[46m'
669  self.WHITE = '\033[47m'
670  self.RESET = '\033[49m'
671 
672 class Style(object):
673  ''' Override ANSI colour classes if colorama is not installed. '''
674  def __init__(self, forceOff=False):
675  if(platform == 'win32' or forceOff): self.disable()
676  else: self.enable()
677  def disable(self):
678  self.DIM = ''
679  self.NORMAL = ''
680  self.BRIGHT = ''
681  self.RESET_ALL = ''
682  def enable(self):
683  self.DIM = '\033[0m'
684  self.NORMAL = '\033[1m'
685  self.BRIGHT = '\033[2m'
686  self.RESET_ALL = '\033[m'
687 
688 
689 
690 class NullWriter(object):
691  ''' Override console output method
692 
693  Example usage:
694  ==============
695  oldstdout = sys.stdout;sys.stdout = NullWriter()
696 
697  Example restore:
698  ================
699  sys.stdout = oldstdout #Re-enable output
700  '''
701  def write(self, arg):
702  pass
def write(self, arg)
Definition: config.py:701
Configuration.
Definition: config.py:22
def setSteeringDistribution(self, value)
Definition: config.py:461
def setValue(self, value)
Definition: config.py:219
def export(self, path='')
Definition: config.py:475
def setCameraSettings(self, framerate=15.0, alignments=None)
Definition: config.py:519
def __init__(self, kwargs)
Definition: config.py:433
def __init__(self, label='', label_short='', method=0, percentile=0.0)
Definition: config.py:592
def __init__(self, forceOff=False)
Definition: config.py:648
def __dir__(self)
Definition: config.py:181
def stripKwargsForUncleanTarget(self, kwargs)
Definition: config.py:479
def __init__(self, readonly=False, filename='tva.cfg')
Definition: config.py:23
def setAccelerationDistribution(self, value)
Definition: config.py:460
def __init__(self, protocol='ccc', maxSpeed=50, nPredictedTrajectories=3, minAcceleration=-2.0, maxAcceleration=2.0, maxSteering=0.2, useFeatures=False, mps_to_kmh=3.6, timeHorizon=1.5, speedBinNum=7, curvilinearBinSize=3, motPatBinNum=40, minSampleSize=50, probRetentionThreshold=0.00001, motPatBinSize=[1, xy_bounds=None, allowImport=True, importLocations='', customSpeedRange=None, results_path='', verbose=0, version='')
Definition: config.py:490
def __init__(self, label, label_short, idx, paramClass, protocol='ccc', prepare=False, kwargs)
Definition: config.py:449
Interaction configruation.
Definition: config.py:432
def setCameraSettings(self, kwargs)
Definition: config.py:443
def getAccelerationDistribution(self)
Definition: config.py:532
def getNPredictedTrajectories(self)
Definition: config.py:527
def __repr__(self)
Definition: config.py:182
def enable(self)
Definition: config.py:682
def disable(self)
Definition: config.py:625
def checkAutoUpdate(self)
Definition: config.py:195
def setSteeringDistribution(self, value)
Definition: config.py:524
def commands()
Definition: config.py:247
def __init__(self, forceOff=False)
Definition: config.py:622
def disable(self)
Definition: config.py:651
def parse(self, parser)
Definition: config.py:221
def enable(self)
Definition: config.py:635
def __init__(self, kwargs)
Definition: config.py:585
def __nonzero__(self)
Definition: config.py:184
def prepare(self)
Definition: config.py:191
def setAccelerationDistribution(self, value)
Definition: config.py:523
def getProbRetentionThreshold(self)
Definition: config.py:536
def prepare(self, args)
Definition: config.py:471
def write(self, justifyCols=[30)
Definition: config.py:200
def setValue(self, key, value)
Definition: config.py:189
def getMethod(self, key)
Definition: config.py:188
The following objects define generic constructors.
def __init__(self, section='section', name='name', default=None, value=None, c_struct='simple', comment='')
Definition: config.py:209
scratch_disk
Initial settings.
Definition: config.py:174
def __init__(self, forceOff=False)
Definition: config.py:674
def disable(self)
Definition: config.py:677
def __init__(self, label='', label_short='', incidenceAngleRanges=[[0)
Definition: config.py:612
def parse(self)
Definition: config.py:193
def enable(self)
Definition: config.py:661
def setCameraSettings(self, kwargs)
Definition: config.py:459