99sys .path .append (os .path .dirname (os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))))
1010import limap .util .io as limapio
1111
12+
1213class NNEndpointsMatcher (BaseMatcher ):
1314 def __init__ (self , extractor , options = BaseMatcherOptions (), device = None ):
1415 super (NNEndpointsMatcher , self ).__init__ (extractor , options )
@@ -87,6 +88,7 @@ def match_segs_with_descinfo_topk(self, descinfo1, descinfo2, topk=10):
8788 matches .flatten ()], axis = 1 )
8889 return matches_t
8990
91+
9092class SuperGlueEndpointsMatcher (BaseMatcher ):
9193 def __init__ (self , extractor , options = BaseMatcherOptions (),
9294 weights = 'outdoor' , device = None ):
@@ -99,10 +101,13 @@ def get_module_name(self):
99101 return "superglue_endpoints"
100102
101103 def match_pair (self , descinfo1 , descinfo2 ):
104+ if len (descinfo1 ['lines' ]) == 0 or len (descinfo1 ['lines' ]) == 0 :
105+ return np .empty ((0 , 2 ))
102106 if self .topk == 0 :
103107 return self .match_segs_with_descinfo (descinfo1 , descinfo2 )
104108 else :
105- return self .match_segs_with_descinfo_topk (descinfo1 , descinfo2 , topk = self .topk )
109+ return self .match_segs_with_descinfo_topk (descinfo1 , descinfo2 ,
110+ topk = self .topk )
106111
107112 def match_segs_with_descinfo (self , descinfo1 , descinfo2 ):
108113 # Setup the inputs for SuperGlue
@@ -199,4 +204,3 @@ def match_segs_with_descinfo_topk(self, descinfo1, descinfo2, topk=10):
199204 matches_t = np .stack ([np .arange (n_lines ).repeat (topk ),
200205 matches .flatten ()], axis = 1 )
201206 return matches_t
202-
0 commit comments