#TODO: decide on a consistent mask format to output.
#Do we want to also accept existing masks and just mask more things?
#consider passing in the matches and source_node to __init__
classMatchOutlierDetector(object):
classOutlierDetector(object):
"""
Documentation
A class which contains several outlier detection methods which all return
True/False masks as pandas data series, which can be used as masks for
the "matches" pandas dataframe which stores match information for each
edge of the graph.
Attributes
----------
"""
def__init__(self,matches,ratio=0.8):
#0.8 is Lowe's paper value -- can be changed.
self.distance_ratio=ratio
self.matches=matches
self.mask=None#start with empty mask? I guess we could accept an input mask.
def__init__(self):
pass
# return mask with self-neighbors set to zero. (query only takes care of literal self-matches on a keypoint basis, not self-matches for the whole image)
#TODO: turn this into a mask-style thing. just returns a mask of bad values
defself_neighbors(self,source_node):
# (query only takes care of literal self-matches on a keypoint basis, not self-matches for the whole image)
defself_neighbors(self,matches):
"""
Returns a df containing self-neighbors that must be removed.
(temporary return val?)
Returns a pandas data series intended to be used as a mask. Each row
is True if it is not matched to a point in the same image (good) and
False if it is (bad.)
Parameters
----------
matches : dataframe
The pandas dataframe output by FlannMatcher.query()
the matches dataframe stored along the edge of the graph
containing matched points with columns containing:
matched image name, query index, train index, and
descriptor distance
source_node: a string used as the key of the matched node
Returns
-------
: dataseries
Intended to mask the matches dataframe. True means the row is not matched to a point in the same image