IVALab Python Libraries
Collection of code for computer vision and robotics with specific API.
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Matcher Class Reference

Generic puzzle piece matching class. More...

Inheritance diagram for Matcher:
Inheritance graph
[legend]

Public Member Functions

def __init__ (self, theParams=CfgMatcher)
 Constructor for the matcher class. More...
 
def compare (self, piece_A, piece_B)
 Compare between two passed puzzle piece data. More...
 
tuple[float, np.ndarray] estimateAffineMatch (self, piece_A, piece_B)
 Estimate the rigid affine transform that aligns piece A to piece B. More...
 
def extractFeature (self, piece)
 Process raw puzzle piece data to obtain encoded description of piece. More...
 
"Matcher" fit (self, groups, list[str]|None labels=None)
 Given raw data regarding expected element instances, identify model to differentiate them if possible for this matcher type. More...
 
"Matcher" fitFromImageSegmented (self, Irgb, Iseg, hasLabs=False)
 Given an image and a segmentation, generate fit. More...
 
def score (self, piece_A, piece_B)
 Compute the score between two passed puzzle piece data. More...
 
def solveMatchedPuzzle (self, puzzle, sol)
 

Static Public Member Functions

tuple[np.ndarray, np.ndarray] pcaFrame (piece)
 Estimate a signed PCA frame from a puzzle piece's foreground pixels. More...
 

Public Attributes

 params
 

Detailed Description

Generic puzzle piece matching class.

Actual instances should use similarity of difference matching sub-classes.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  theParams = CfgMatcher 
)

Constructor for the matcher class.

Parameters
[in]theParamsThe matcher configuration (optional).

Reimplemented in MatchSimilar, SIFTCV, PCA, Moments, HistogramCV, Distance, and MatchDifferent.

Member Function Documentation

◆ compare()

def compare (   self,
  piece_A,
  piece_B 
)

Compare between two passed puzzle piece data.

This member function should be overloaded.

Parameters
[in]piece_APuzzle piece A instance.
[in]piece_BPuzzle piece B instance.
[out]Outcomeof matching classification, when function overloaded.

Reimplemented in Sift, MatchSimilar, and MatchDifferent.

◆ estimateAffineMatch()

tuple[float, np.ndarray] estimateAffineMatch (   self,
  piece_A,
  piece_B 
)

Estimate the rigid affine transform that aligns piece A to piece B.

The transform maps global pixel coordinates from piece_A into the global coordinate frame of piece_B. Its rotation is determined by their signed PCA frames and its translation maps the A centroid onto the B centroid.

Returns
(rotation_degrees, affine) where affine is a 3x3 homogeneous rigid transform.

◆ extractFeature()

def extractFeature (   self,
  piece 
)

Process raw puzzle piece data to obtain encoded description of piece.

Use to recognize/associate the piece given new measurements. This member function should be overloaded.

Parameters
[in]pieceTemplate instance saving a piece's info.
[out]featVecThe "feature" vector.

Reimplemented in SIFTCV, PCA, Moments, HistogramCV, Distance, ColorBoWMatcher, and Edge.

◆ fit()

"Matcher" fit (   self,
  groups,
list[str] | None   labels = None 
)

Given raw data regarding expected element instances, identify model to differentiate them if possible for this matcher type.

This base class does nothing. Overload as fitting.

Parameters
groupsList of (3, N) RGB matrices forming the database.
labelsOptional list of human-readable names, one per group. Auto-generated as "group_0", "group_1", ... if None.
Returns
Self, to allow method chaining (e.g., matcher.fit(groups).query(q)).

◆ fitFromImageSegmented()

"Matcher" fitFromImageSegmented (   self,
  Irgb,
  Iseg,
  hasLabs = False 
)

Given an image and a segmentation, generate fit.

This base class does nothing. Overload as fitting.

Permits fitting based on two images, one with all objects of interest in it as a color image and the second a segmentation isolating the objects. It should be considered binary in nature, then no labels assumed. If it has labels (each unique value is the label), then snag from Iseg as labels.

Parameters
[in]IrgbSource color image.
[in]IsegBinary segmentation of image, or label segmentation.
[in]hasLabsIseg has labels and is interpreted as binary. Default: False.

Reimplemented in ColorBoWMatcher.

◆ pcaFrame()

tuple[np.ndarray, np.ndarray] pcaFrame (   piece)
static

Estimate a signed PCA frame from a puzzle piece's foreground pixels.

Parameters
[in]pieceTemplate puzzle piece.
Returns
(center, frame) where center is the global pixel centroid and frame is a 2x2 right-handed rotation matrix whose first column is the major PCA axis.

◆ score()

def score (   self,
  piece_A,
  piece_B 
)

Compute the score between two passed puzzle piece data.

Parameters
[in]piece_ATemplate instance saving a piece's info.
[in]piece_BTemplate instance saving a piece's info.
[out]Distanceof the feature vectors. (Overload if not proper).

Reimplemented in Sift, SIFTCV, PCA, Moments, HistogramCV, and ColorBoWMatcher.

◆ solveMatchedPuzzle()

def solveMatchedPuzzle (   self,
  puzzle,
  sol 
)

Reimplemented in SIFTCV.

Member Data Documentation

◆ params

params

The documentation for this class was generated from the following file: