tvaLib
Namespaces | Functions | Variables
C:/Home/Documents/workspace/tvaLib/main.py File Reference

Go to the source code of this file.

Namespaces

 main
 

Functions

def main.main ()
 main() More...
 

Variables

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