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

 Initial settings. More...

Detailed Description


Definition at line 22 of file

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 23 of file

23  def __init__(self, readonly=False, filename='tva.cfg'):
24  self.filename=filename
25  self.config = ConfigParser()
28 = OrderedDict()
29['dir'] = ConfigValue('Main', default='', comment='Root directory where the video data and metadata database is stored and output will be written')
30['dbn'] = ConfigValue('Main', default='scene.sqlite', comment='Metadata database filename, typically scene.sqlite')
31['meta_db'] = ConfigValue('Main', default='meta_db.csv', comment='Optional metadata csv to accompany scene.sqlite')
32['path_to_trafint'] = ConfigValue('Main', default='', comment='Root path to Traffic-Intelligence')
33['autoflush_version'] = ConfigValue('Main', default=False, comment='Automatically flush cached data of an older version')
34['autoflush_ver_depth'] = ConfigValue('Main', default=3, comment='Version depth to determine data flushing')
35['debug'] = ConfigValue('Main', default=False, comment='Dev debugging mode')
36['language'] = ConfigValue('Main', default='en', comment='Plotting language, some interface elements also supported')
37['advanced_runtime'] = ConfigValue('Main', default=False, comment='Force runtime even if some dependencies couldn\'t be loaded')
38['s_proc_max_exec_time_in_s'] = ConfigValue('Main', default=300, comment='Maximum runtime of subprocesses')
39['readonly'] = ConfigValue('Main', default=False, comment='If set to True, this config will not be modified by the program')
40['disable_colour'] = ConfigValue('Main', default=False, comment='If set to True, coloured text mode will be forced to disabled')
41['output_folder'] = ConfigValue('Main', default='Analysis', comment='All output will be dumped in a folder with this name in the root directory')
42['calibration_folder'] = ConfigValue('Main', default='Calibration', comment='Calibration folder')
43['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['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['classification_method'] = ConfigValue('Main', default=0, comment='Classification method to be used. 0=speed, 1=hog')
46['alignmentOverride'] = ConfigValue('Main', default=False, comment='Set to true to override the check for alignment data completion.')
48['interactive_max_col_size1'] = ConfigValue('Interface', default=20, comment='Interactive site selection column 1 width')
49['interactive_max_col_size2'] = ConfigValue('Interface', default=40, comment='Interactive site selection column 2 width')
50['interactive_max_col_size3'] = ConfigValue('Interface', default=60, comment='Interactive site selection column 3 width')
52['MOT_max_distance'] = ConfigValue('MOT', default=10.0, comment='Maximum search distance for MOT')
53['MOT_max_generations'] = ConfigValue('MOT', default=0, comment='Maximum genetic algorithm generations to generate during optimization procedure')
54['MOT_population_size'] = ConfigValue('MOT', default=20, comment='Maximum genetic algorithm population size to simulate each generation')
55['MOT_end_criteria'] = ConfigValue('MOT', default=0.95, comment='MOT optimization will end after reaching this score')
56['MOT_save_all'] = ConfigValue('MOT', default=False, comment='MOT optimization will save all the files generated when set to True')
57['MOT_save_best'] = ConfigValue('MOT', default=False, comment='MOT optimization will save best file generated when set to True')
58['MOT_save_all_dir_name'] = ConfigValue('MOT', default='MOT_SavedFiles', comment='Directory where MOT analysis results (all) will be saved')
60['video_out_fourcc'] = ConfigValue('VideoData', default='MJPG', comment='fourcc codec to use when recoding; e.g. MJPG or X264')
61['mps_kmh'] = ConfigValue('VideoData', default=3.6, comment='I.e. 3.6. It is not recommended to change this')
62['max_speed'] = ConfigValue('VideoData', default=100, comment='Maximum possible observed speed assumed, in km/h')
63['timehorizon'] = ConfigValue('VideoData', default=10.0, comment='Maximum time in future to predict conflicts, in seconds')
64['loop_radius'] = ConfigValue('VideoData', default=3, comment='Radius size of virtual loops, in metres')
65['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['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.')
68['pred_minSampleSize'] = ConfigValue('DMP', default=10, comment='Minimum sample size to make a DMP motion prediction')
69['pred_probability_threshold'] = ConfigValue('DMP', default=0.00001, comment='Minimum prediction probability threshold for a motion pattern to be conserved')
71['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['up_maxDistance'] = ConfigValue('Conflicts', default=50.0, comment='Maximum distance between road users in order to consider them a pair')
73['col_probability_threshold'] = ConfigValue('Conflicts', default=0.001, comment='Minimum collision probability threshold for a conflict to be registered')
75['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['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['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='')
79['draw_max_traj'] = ConfigValue('Plotting', default=300, comment='Maximum trajectories to work with with visual tools')
80['plot_dropped_traj'] = ConfigValue('Plotting', default=False, comment='Plot trajectories that were dropped in a separate folder')
81['plot_text_size'] = ConfigValue('Plotting', default=16, comment='Size of text')
82['cm_colour'] = ConfigValue('Plotting', default='hot', comment='\n')
83['speed_map_u_scale'] = ConfigValue('Plotting', default=50, comment='Upper speed limit to plot histograms to')
84['hex_grid_dimension'] = ConfigValue('Plotting', default=[60,60], c_struct='list1D', comment='Dimensions for hex grid')
85['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['figsize'] = ConfigValue('Plotting', default=[15.0,12.0], c_struct='list1D', comment='Default figure size')
87['minVFcount'] = ConfigValue('Plotting', default=10, comment='Minimum vectors to draw vector field')
88['TTCthreshSeconds'] = ConfigValue('Plotting', default=1.5, comment='Maximum value of TTC for threshold TTC plotting, in seconds')
89['font_family'] = ConfigValue('Plotting', default='Arial', comment='Plotting font')
90['fig_bg_colour'] = ConfigValue('Plotting', default='#ffffff', comment='Plotting background (transparent if none)')
92['disp_timehorizon'] = ConfigValue('Analysis', default=5.0, comment='Maximum time in future to compound conflict data, in seconds')
94['corridorMinProximity'] = ConfigValue('Network', default=5.0, comment='')
95['corridorMinContDistance'] = ConfigValue('Network', default=20.0, comment='')
96['connectorSearchDistance'] = ConfigValue('Network', default=5.0, comment='')
97['intersectionDistanceFactor'] = ConfigValue('Network', default=3.0, comment='')
99['f_bb_max_outside_dist'] = ConfigValue('Filter Params', default=2.0, comment='')
100['f_bb_containment_threshold'] = ConfigValue('Filter Params', default=0.96, comment='')
101['f_bb_loopback_ver_frames'] = ConfigValue('Filter Params', default=20, comment='')
102['f_so_hard_maxSpeed'] = ConfigValue('Filter Params', default=6.0, comment='')
103['f_so_soft_maxSpeed'] = ConfigValue('Filter Params', default=2.0, comment='')
104['f_so_max_angle'] = ConfigValue('Filter Params', default=45.0, comment='')
105['f_te_config_min_traj_len'] = ConfigValue('Filter Params', default=20, comment='')
106['f_td_min_sep_distance'] = ConfigValue('Filter Params', default=8.0, comment='')
107['f_td_min_sep_velocity'] = ConfigValue('Filter Params', default=8.0, comment='')
108['f_cl_align_window_m'] = ConfigValue('Filter Params', default=4.0, comment='')
110['fs_search_window'] = ConfigValue('Filter_Stitch', default=50, comment='')
111['fs_max_dwell_time'] = ConfigValue('Filter_Stitch', default=0.66, comment='')
112['fs_speed_adj_factor'] = ConfigValue('Filter_Stitch', default=1000.0, comment='')
113['fs_speed_sim_limit_min'] = ConfigValue('Filter_Stitch', default=10, comment='')
114['fs_speed_similarity_lim'] = ConfigValue('Filter_Stitch', default=0.30, comment='')
115['fs_search_radius'] = ConfigValue('Filter_Stitch', default=8.0, comment='')
116['fs_stop_speed_det_lim'] = ConfigValue('Filter_Stitch', default=5.5, comment='')
117['fs_angle_similairty_deg'] = ConfigValue('Filter_Stitch', default=80.0, comment='')
119['class_svmType'] = ConfigValue('HOGClassification',default=100, comment='')
120['class_kernelType'] = ConfigValue('HOGClassification',default=2, comment='')
121['class_degree'] = ConfigValue('HOGClassification',default=0, comment='')
122['class_gamma'] = ConfigValue('HOGClassification',default=1, comment='')
123['class_coef0'] = ConfigValue('HOGClassification',default=0, comment='')
124['class_cvalue'] = ConfigValue('HOGClassification',default=1, comment='')
125['class_nu'] = ConfigValue('HOGClassification',default=0, comment='')
126['class_svmP'] = ConfigValue('HOGClassification',default=0, comment='')
127['class_useAllSites'] = ConfigValue('HOGClassification',default=False, comment='')
128['class_min_n_features'] = ConfigValue('HOGClassification',default=10, comment='')
129['class_PBV_SVMFilename'] = ConfigValue('HOGClassification',default='modelPBV.xml', comment='filename of the general ped/cyc/veh SVM classifier')
130['class_BV_SVMFilename'] = ConfigValue('HOGClassification',default='modelBV.xml', comment='filename of the cyc/veh SVM classifier')
131['class_PV_SVMFilename'] = ConfigValue('HOGClassification',default='modelPV.xml', comment='filename of the cyc/veh SVM classifier')
132['class_PB_SVMFilename'] = ConfigValue('HOGClassification',default='modelPB.xml', comment='filename of the cyc/veh SVM classifier')
133['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['class_minNPixels'] = ConfigValue('HOGClassification',default=800, comment='min number of pixels in cropped image to classify by SVM')
135['class_hogRescaleSize'] = ConfigValue('HOGClassification',default=[64,64], c_struct='list1D', comment='square size to resize image crops for HoG computation')
136['class_hogNOrientations'] = ConfigValue('HOGClassification',default=9, comment='number of HoG orientation')
137['class_hogNPixelsPerCell'] = ConfigValue('HOGClassification',default=[8,8], c_struct='list1D', comment='number of pixels per cell for HoG computation')
138['class_hogNCellsPerBlock'] = ConfigValue('HOGClassification',default=[2,2], c_struct='list1D', comment='number of cells per block for HoG computation')
139['class_hogBlockNorm'] = ConfigValue('HOGClassification',default='L1-sqrt', comment='block normalization method (L1, L1-sqrt, L2, L2-Hys)')
140['class_speedAggregationMeth'] = ConfigValue('HOGClassification',default='median', comment='method to aggregate road user speed')
141['class_nFramesIgnoreAtEnds'] = ConfigValue('HOGClassification',default=2, comment='number of frames to ignore at both ends of a series (noisy)')
142['class_speedAggregationQuant'] = ConfigValue('HOGClassification',default=50, comment='quantile for the speed aggregation, if quantile is chosen')
143['class_minSpeedEquiprobable'] = ConfigValue('HOGClassification',default=3.33, comment='speed value below which all classes are equiprobable (distributions give odd values there) (km/h)')
144['class_maxPercentUnknown'] = ConfigValue('HOGClassification',default=0.66, comment='maximum proportion of the instants with unknow appearance classification to use speed information')
145['class_maxPedestrianSpeed'] = ConfigValue('HOGClassification',default=10.0, comment='maximum pedestrian speed (agregate: mean, median, 85th centile, etc.) 10 km/h')
146['class_maxCyclistSpeed'] = ConfigValue('HOGClassification',default=30.0, comment='maximum cyclist speed (agregate: mean, median, 85th centile, etc.) 30 km/h (3xped)')
147['class_meanPedestrianSpeed'] = ConfigValue('HOGClassification',default=4.91, comment='mean pedestrian speed (in a normal distribution) km/h')
148['class_stdPedestrianSpeed'] = ConfigValue('HOGClassification',default=0.88, comment='standard deviation pedestrian speed (in a normal distribution) km/h')
149['class_meanCyclistSpeed'] = ConfigValue('HOGClassification',default=15.0, comment='mean pedestrian speed (in a normal distribution) km/h')
150['class_stdCyclistSpeed'] = ConfigValue('HOGClassification',default=5.0, comment='standard deviation pedestrian speed (in a normal distribution) km/h')
151['class_meanVehicleSpeed'] = ConfigValue('HOGClassification',default=30.00, comment='mean vehicle speed (in a normal distribution) km/h')
152['class_stdVehicleSpeed'] = ConfigValue('HOGClassification',default=7.6, comment='standard deviation vehicle speed (in a normal distribution) km/h')
153['class_locationCyclistSpeed'] = ConfigValue('HOGClassification',default=2.31, comment='to multiply the parameters by a, loc = loc+ln(a)')
154['class_scaleCyclistSpeed'] = ConfigValue('HOGClassification',default=0.42, comment='')
155['class_candidates'] = ConfigValue('HOGClassification',default=[1,2,4], c_struct='list1D', comment='The user type numbers to identify when classifying')
157['event_label_1'] = ConfigValue('Event Labels' ,default='Event 1', comment='')
158['event_label_2'] = ConfigValue('Event Labels' ,default='Event 2', comment='')
159['event_label_3'] = ConfigValue('Event Labels' ,default='Event 3', comment='')
160['event_label_4'] = ConfigValue('Event Labels' ,default='Event 4', comment='')
161['event_label_5'] = ConfigValue('Event Labels' ,default='Event 5', comment='')
162['event_label_6'] = ConfigValue('Event Labels' ,default='', comment='')
163['event_label_7'] = ConfigValue('Event Labels' ,default='', comment='')
164['event_label_8'] = ConfigValue('Event Labels' ,default='', comment='')
165['event_label_9'] = ConfigValue('Event Labels' ,default='', comment='')
166['event_label_10'] = ConfigValue('Event Labels' ,default='', comment='')
168  self.prepare()
169  updateNeeded = self.checkAutoUpdate()
170  self.parse()
171  if(updateNeeded): self.write()
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]

Member Function Documentation

◆ __dir__()

def include.config.Config.__dir__ (   self)

Definition at line 181 of file

181  def __dir__(self): return

◆ __getattr__()

def include.config.Config.__getattr__ (   self,

Definition at line 185 of file

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

◆ __nonzero__()

def include.config.Config.__nonzero__ (   self)

Definition at line 184 of file

184  def __nonzero__(self): return True

◆ __repr__()

def include.config.Config.__repr__ (   self)

Definition at line 182 of file

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

◆ __str__()

def include.config.Config.__str__ (   self)

Definition at line 183 of file

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

◆ checkAutoUpdate()

def include.config.Config.checkAutoUpdate (   self)

Definition at line 195 of file

195  def checkAutoUpdate(self):
196  for name in
197  if(not self.config.has_option([name].section,name)): return True
198  return False

◆ getMethod()

def include.config.Config.getMethod (   self,

Definition at line 188 of file

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

◆ parse()

def include.config.Config.parse (   self)

Definition at line 193 of file

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

◆ prepare()

def include.config.Config.prepare (   self)

Definition at line 191 of file

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

◆ setValue()

def include.config.Config.setValue (   self,

Definition at line 189 of file

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

◆ write()

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

Definition at line 200 of file

200  def write(self, justifyCols=[30,50]):
201  with open(self.filename, 'w') as configfile:
202  for section in set([[name].section for name in]):
203  configfile.write('['+section+']\n')
204  for name in
205  if([name].section == section): configfile.write(name.ljust(justifyCols[0])+' = '+str([name].value).ljust(justifyCols[1])+' ; '+str([name].comment)+'\n')
206  configfile.write('\n')

Member Data Documentation

◆ config


Definition at line 25 of file

◆ data

Definition at line 28 of file

◆ event_labels


Definition at line 179 of file

◆ filename


Definition at line 24 of file

◆ scratch_disk


Initial settings.

Definition at line 174 of file

◆ temp_dir


Definition at line 174 of file

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