@@ -50,7 +50,7 @@ def reduce_samples(inputSfMData, imagePairsList, samplesFolder, featuresFolder,
5050
5151 # Retrieve list of images pairs to process
5252 plist = avmic .PairSet ()
53- if not avmic .loadPairsFromFile (imagePairsList , plist , 0 , - 1 , False ):
53+ if not avmic .loadPairsFromFile (imagePairsList , plist , False ):
5454 raise RuntimeError ("Error in image pairs list loading" )
5555
5656 # build a list of image pairs indexed by their reference images
@@ -72,38 +72,64 @@ def reduce_samples(inputSfMData, imagePairsList, samplesFolder, featuresFolder,
7272 for referenceId , pairs in plistByRef .items ():
7373 logging .info (f"Processing reference #{ referenceId } " , flush = True )
7474
75+ # Output features file for the reference image
7576 path_coords = os .path .join (samplesFolder , str (referenceId ) + ".npy" )
7677
78+ # Load file with coordinates for a given reference view
79+ # This is an array of size [n, 3], where n is the number of coordinates used in this reference view
80+ # first column is the x coordinate
81+ # second column is the y coordinate
82+ # third column is the 1
83+ # fourth column is the scale
7784 try :
7885 coords_A_B = np .load (path_coords )
7986 except :
8087 coords_A_B = np .array (())
8188
89+ # Transform this array to a set of feature points for the reference view
90+ # referenceId may already exists in regionMap, because the reference view may have been used as
91+ # a matching view. We therefore return the offset in the list of features to be able to compute
92+ # indices for matches
8293 refOffset = export_features (regionsMap , referenceId , coords_A_B )
8394
95+ # For all pairs with the current reference view
8496 for item in pairs :
8597
8698 otherId = item [1 ]
8799
100+ # Load file with precomputed matches for a given reference view
101+ # This is an array of size [n, 3], where n is the number of matches
102+ # first column is the x coordinates in the other image
103+ # second column is the y coordinates in the other image
104+ # third column is the confidence score
105+ # fourth column is the scale
88106 path_samples = os .path .join (samplesFolder , str (referenceId ) + "_" + str (otherId ) + ".npy" )
89107
90108 try :
91109 match_A_B = np .load (path_samples )
92110 except :
93111 continue
94112
113+ # Transform this array to a set of feature points for the other view
114+ # otherId may already exists in regionMap, because the view may have been used as
115+ # another matching view. We therefore return the offset in the list of features to be able to compute
116+ # indices for matches
95117 otherOffset = export_features (regionsMap , otherId , match_A_B )
96118
119+ # Build a list of matches using offset and indices
97120 pos = 0
98121 matches = avmatch .IndMatches ()
99122 for rowId in range (0 , match_A_B .shape [0 ]):
100123 if match_A_B [rowId , 2 ] > 1e-6 :
101124 matches .append (avmatch .IndMatch (refOffset + rowId , otherOffset + pos ))
102125 pos = pos + 1
103126
127+ # Save matches for pair per desc.
128+ # Obviously, here we only have on descriptor type
104129 perdesc = avmatch .MatchesPerDescType ()
105130 perdesc [avmatch .EImageDescriberType_SIFT ] = matches
106131
132+ # Save matches for pair per desc in a global container
107133 pair = avmatch .Pair (referenceId , otherId )
108134 global_matches [pair ] = perdesc
109135
@@ -115,6 +141,8 @@ def reduce_samples(inputSfMData, imagePairsList, samplesFolder, featuresFolder,
115141if __name__ == '__main__' :
116142 import argparse
117143
144+ logger = logging .getLogger ().setLevel (logging .INFO )
145+
118146 # create the top-level parser
119147 parser = argparse .ArgumentParser (prog = 'romaProcessor' )
120148
0 commit comments