Ejemplo n.º 1
0
def make_track_greedy_decomposition(gEpG,radius,keypoint_selector=2,cosine_threshold=0.9999):
    if type(keypoint_selector)==int:
        kp_functor=keypoint_selectors[keypoint_selector]
    else:
        kp_functor=keypoint_selector
    make_structure = make_structure_factory(cosine_threshold)
    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 safe_track_greedy_decomposition(T):
        mem_safe_tracks=safe_decomposition([T])
        if len(mem_safe_tracks)==1:
            return track_greedy_decomposition(T)
        else:
            print len(mem_safe_tracks),' splitted connected components' 
            tracks=[]
            for t in mem_safe_tracks:
                tracks+=track_greedy_decomposition(t)
            return tracks
    return safe_track_greedy_decomposition
Ejemplo n.º 2
0
 def __init__(self,gEpG,T):
     self.gEpG=gEpG
     self.T=T
     make_structure = make_structure_factory(1.)
     ps=make_structure(T,gEpG)
     self.ps=make_structure(T,gEpG)