def track_greedy_decomposition(T): """ track_greedy_decomposition(T): given: kps,cliques,factors,kps2cliques tracks = {} excluded_keypoints = {} while T = initialize track (...) while kp = select keypoint (...) add keypoint kp to T add track T to tracks return tracks """ # Problem Structure ps=make_structure(T,gEpG) tracks={} track_initialization_is_possible = True excluded_keypoints=set() iteration=0 while track_initialization_is_possible: current_track=init_track( excluded_keypoints, ps.keypoints, ps.cliques, ps.distances, ps.kpsToCliques) if not len(current_track)<2: support_expansion_is_possible=True while support_expansion_is_possible: kp=kp_functor( ps.cliques, ps.distances, ps.kpsToCliques, current_track, excluded_keypoints, radius, len(ps.keypoints)) if kp == -1: support_expansion_is_possible = False else: current_track.add(kp) else: track_initialization_is_possible = False excluded_keypoints.update(current_track) tracks[iteration]=list(current_track) iteration+=1 return build_tracks(T,tracks,ps.keypoints)
def solve_for(self,radius,cosine_threshold,selector_method=0): ps=filter_problem_structure(self.ps,cosine_threshold) tracks={} track_initialization_is_possible = True excluded_keypoints=set() iteration=0 while track_initialization_is_possible: current_track=init_track( excluded_keypoints, ps.keypoints, ps.cliques, ps.distances, ps.kpsToCliques) if not len(current_track)<2: support_expansion_is_possible=True while support_expansion_is_possible: kp=keypoint_selectors[selector_method]( ps.cliques, ps.distances, ps.kpsToCliques, current_track, excluded_keypoints, radius, len(ps.keypoints)) if kp == -1: support_expansion_is_possible = False else: current_track.add(kp) #print '[track decomposition] track {} += kp {}'.format( # iteration,kp) else: track_initialization_is_possible = False excluded_keypoints.update(current_track) tracks[iteration]=list(current_track) iteration+=1 #print '[track decomposition] orphans:',[i for i in range(len(self.kps)) if not i in excluded_keypoints] return build_tracks(self.T,tracks,ps.keypoints)