tvaLib
Public Member Functions | Public Attributes | List of all members
include.config.Config Class Reference

Configuration. More...

Public Member Functions

def __init__ (self, readonly=False, filename='tva.cfg')
 
def __dir__ (self)
 
def __repr__ (self)
 
def __str__ (self)
 
def __nonzero__ (self)
 
def __getattr__ (self, key)
 
def getMethod (self, key)
 
def setValue (self, key, value)
 
def prepare (self)
 
def parse (self)
 
def checkAutoUpdate (self)
 
def write (self, justifyCols=[30)
 

Public Attributes

 filename
 
 config
 
 data
 
 scratch_disk
 Initial settings. More...
 
 temp_dir
 
 event_labels
 

Detailed Description

Configuration.

Definition at line 22 of file config.py.

Constructor & Destructor Documentation

◆ __init__()

def include.config.Config.__init__ (   self,
  readonly = False,
  filename = 'tva.cfg' 
)

Definition at line 23 of file config.py.

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 

Member Function Documentation

◆ __dir__()

def include.config.Config.__dir__ (   self)

Definition at line 181 of file config.py.

181  def __dir__(self): return self.data.keys()

◆ __getattr__()

def include.config.Config.__getattr__ (   self,
  key 
)

Definition at line 185 of file config.py.

185  def __getattr__(self, key):
186  try: return self.data[key].value
187  except KeyError: raise AttributeError, key

◆ __nonzero__()

def include.config.Config.__nonzero__ (   self)

Definition at line 184 of file config.py.

184  def __nonzero__(self): return True

◆ __repr__()

def include.config.Config.__repr__ (   self)

Definition at line 182 of file config.py.

182  def __repr__(self): return '<tvaLib configuration settings>'

◆ __str__()

def include.config.Config.__str__ (   self)

Definition at line 183 of file config.py.

183  def __str__(self): return 'tvaLib configuration settings'

◆ checkAutoUpdate()

def include.config.Config.checkAutoUpdate (   self)

Definition at line 195 of file config.py.

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 

◆ getMethod()

def include.config.Config.getMethod (   self,
  key 
)

Definition at line 188 of file config.py.

188  def getMethod(self, key): return self.data[key]

◆ parse()

def include.config.Config.parse (   self)

Definition at line 193 of file config.py.

193  def parse(self):
194  for name in self.data: self.data[name].parse(parser=self.config)

◆ prepare()

def include.config.Config.prepare (   self)

Definition at line 191 of file config.py.

191  def prepare(self):
192  for name in self.data: self.data[name].name = name

◆ setValue()

def include.config.Config.setValue (   self,
  key,
  value 
)

Definition at line 189 of file config.py.

189  def setValue(self, key, value): self.data[key].setValue(value)
190 

◆ write()

def include.config.Config.write (   self,
  justifyCols = [30 
)

Definition at line 200 of file config.py.

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 

Member Data Documentation

◆ config

include.config.Config.config

Definition at line 25 of file config.py.

◆ data

include.config.Config.data

Definition at line 28 of file config.py.

◆ event_labels

include.config.Config.event_labels

Definition at line 179 of file config.py.

◆ filename

include.config.Config.filename

Definition at line 24 of file config.py.

◆ scratch_disk

include.config.Config.scratch_disk

Initial settings.

Definition at line 174 of file config.py.

◆ temp_dir

include.config.Config.temp_dir

Definition at line 174 of file config.py.


The documentation for this class was generated from the following file: