OpenCV 2.4.8

org.opencv.features2d
Class GenericDescriptorMatcher

java.lang.Object
  extended by org.opencv.features2d.GenericDescriptorMatcher

public class GenericDescriptorMatcher
extends java.lang.Object

Abstract interface for extracting and matching a keypoint descriptor. There are also "DescriptorExtractor" and "DescriptorMatcher" for these purposes but their interfaces are intended for descriptors represented as vectors in a multidimensional space. GenericDescriptorMatcher is a more generic interface for descriptors. DescriptorMatcher and GenericDescriptorMatcher have two groups of match methods: for matching keypoints of an image with another image or with an image set.

class GenericDescriptorMatcher

// C++ code:

public:

GenericDescriptorMatcher();

virtual ~GenericDescriptorMatcher();

virtual void add(const vector& images,

vector >& keypoints);

const vector& getTrainImages() const;

const vector >& getTrainKeypoints() const;

virtual void clear();

virtual void train() = 0;

virtual bool isMaskSupported() = 0;

void classify(const Mat& queryImage,

vector& queryKeypoints,

const Mat& trainImage,

vector& trainKeypoints) const;

void classify(const Mat& queryImage,

vector& queryKeypoints);

/ *

void match(const Mat& queryImage, vector& queryKeypoints,

const Mat& trainImage, vector& trainKeypoints,

vector& matches, const Mat& mask=Mat()) const;

void knnMatch(const Mat& queryImage, vector& queryKeypoints,

const Mat& trainImage, vector& trainKeypoints,

vector >& matches, int k,

const Mat& mask=Mat(), bool compactResult=false) const;

void radiusMatch(const Mat& queryImage, vector& queryKeypoints,

const Mat& trainImage, vector& trainKeypoints,

vector >& matches, float maxDistance,

const Mat& mask=Mat(), bool compactResult=false) const;

/ *

void match(const Mat& queryImage, vector& queryKeypoints,

vector& matches, const vector& masks=vector());

void knnMatch(const Mat& queryImage, vector& queryKeypoints,

vector >& matches, int k,

const vector& masks=vector(), bool compactResult=false);

void radiusMatch(const Mat& queryImage, vector& queryKeypoints,

vector >& matches, float maxDistance,

const vector& masks=vector(), bool compactResult=false);

virtual void read(const FileNode&);

virtual void write(FileStorage&) const;

virtual Ptr clone(bool emptyTrainData=false) const = 0;

protected:...

};

See Also:
org.opencv.features2d.GenericDescriptorMatcher

Field Summary
static int FERN
           
static int ONEWAY
           
 
Method Summary
 void add(java.util.List<Mat> images, java.util.List<MatOfKeyPoint> keypoints)
          Adds images and their keypoints to the training collection stored in the class instance.
 void classify(Mat queryImage, MatOfKeyPoint queryKeypoints)
          Classifies keypoints from a query set.
 void classify(Mat queryImage, MatOfKeyPoint queryKeypoints, Mat trainImage, MatOfKeyPoint trainKeypoints)
          Classifies keypoints from a query set.
 void clear()
          Clears a train collection (images and keypoints).
 GenericDescriptorMatcher clone()
           
 GenericDescriptorMatcher clone(boolean emptyTrainData)
           
static GenericDescriptorMatcher create(int matcherType)
           
 boolean empty()
           
 java.util.List<Mat> getTrainImages()
          Returns a train image collection.
 java.util.List<MatOfKeyPoint> getTrainKeypoints()
          Returns a train keypoints collection.
 boolean isMaskSupported()
          Returns true if a generic descriptor matcher supports masking permissible matches.
 void knnMatch(Mat queryImage, MatOfKeyPoint queryKeypoints, java.util.List<MatOfDMatch> matches, int k)
          Finds the k best matches for each query keypoint.
 void knnMatch(Mat queryImage, MatOfKeyPoint queryKeypoints, java.util.List<MatOfDMatch> matches, int k, java.util.List<Mat> masks, boolean compactResult)
          Finds the k best matches for each query keypoint.
 void knnMatch(Mat queryImage, MatOfKeyPoint queryKeypoints, Mat trainImage, MatOfKeyPoint trainKeypoints, java.util.List<MatOfDMatch> matches, int k)
          Finds the k best matches for each query keypoint.
 void knnMatch(Mat queryImage, MatOfKeyPoint queryKeypoints, Mat trainImage, MatOfKeyPoint trainKeypoints, java.util.List<MatOfDMatch> matches, int k, Mat mask, boolean compactResult)
          Finds the k best matches for each query keypoint.
 void match(Mat queryImage, MatOfKeyPoint queryKeypoints, Mat trainImage, MatOfKeyPoint trainKeypoints, MatOfDMatch matches)
          Finds the best match in the training set for each keypoint from the query set.
 void match(Mat queryImage, MatOfKeyPoint queryKeypoints, Mat trainImage, MatOfKeyPoint trainKeypoints, MatOfDMatch matches, Mat mask)
          Finds the best match in the training set for each keypoint from the query set.
 void match(Mat queryImage, MatOfKeyPoint queryKeypoints, MatOfDMatch matches)
          Finds the best match in the training set for each keypoint from the query set.
 void match(Mat queryImage, MatOfKeyPoint queryKeypoints, MatOfDMatch matches, java.util.List<Mat> masks)
          Finds the best match in the training set for each keypoint from the query set.
 void radiusMatch(Mat queryImage, MatOfKeyPoint queryKeypoints, java.util.List<MatOfDMatch> matches, float maxDistance)
          For each query keypoint, finds the training keypoints not farther than the specified distance.
 void radiusMatch(Mat queryImage, MatOfKeyPoint queryKeypoints, java.util.List<MatOfDMatch> matches, float maxDistance, java.util.List<Mat> masks, boolean compactResult)
          For each query keypoint, finds the training keypoints not farther than the specified distance.
 void radiusMatch(Mat queryImage, MatOfKeyPoint queryKeypoints, Mat trainImage, MatOfKeyPoint trainKeypoints, java.util.List<MatOfDMatch> matches, float maxDistance)
          For each query keypoint, finds the training keypoints not farther than the specified distance.
 void radiusMatch(Mat queryImage, MatOfKeyPoint queryKeypoints, Mat trainImage, MatOfKeyPoint trainKeypoints, java.util.List<MatOfDMatch> matches, float maxDistance, Mat mask, boolean compactResult)
          For each query keypoint, finds the training keypoints not farther than the specified distance.
 void read(java.lang.String fileName)
          Reads a matcher object from a file node.
 void train()
          Trains descriptor matcher
 void write(java.lang.String fileName)
          Writes a match object to a file storage.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FERN

public static final int FERN
See Also:
Constant Field Values

ONEWAY

public static final int ONEWAY
See Also:
Constant Field Values
Method Detail

add

public void add(java.util.List<Mat> images,
                java.util.List<MatOfKeyPoint> keypoints)

Adds images and their keypoints to the training collection stored in the class instance.

Parameters:
images - Image collection.
keypoints - Point collection. It is assumed that keypoints[i] are keypoints detected in the image images[i].
See Also:
org.opencv.features2d.GenericDescriptorMatcher.add

classify

public void classify(Mat queryImage,
                     MatOfKeyPoint queryKeypoints)

Classifies keypoints from a query set.

The method classifies each keypoint from a query set. The first variant of the method takes a train image and its keypoints as an input argument. The second variant uses the internally stored training collection that can be built using the GenericDescriptorMatcher.add method.

The methods do the following:

  • Call the GenericDescriptorMatcher.match method to find correspondence between the query set and the training set.
  • Set the class_id field of each keypoint from the query set to class_id of the corresponding keypoint from the training set.

Parameters:
queryImage - Query image.
queryKeypoints - Keypoints from a query image.
See Also:
org.opencv.features2d.GenericDescriptorMatcher.classify

classify

public void classify(Mat queryImage,
                     MatOfKeyPoint queryKeypoints,
                     Mat trainImage,
                     MatOfKeyPoint trainKeypoints)

Classifies keypoints from a query set.

The method classifies each keypoint from a query set. The first variant of the method takes a train image and its keypoints as an input argument. The second variant uses the internally stored training collection that can be built using the GenericDescriptorMatcher.add method.

The methods do the following:

  • Call the GenericDescriptorMatcher.match method to find correspondence between the query set and the training set.
  • Set the class_id field of each keypoint from the query set to class_id of the corresponding keypoint from the training set.

Parameters:
queryImage - Query image.
queryKeypoints - Keypoints from a query image.
trainImage - Train image.
trainKeypoints - Keypoints from a train image.
See Also:
org.opencv.features2d.GenericDescriptorMatcher.classify

clear

public void clear()

Clears a train collection (images and keypoints).

See Also:
org.opencv.features2d.GenericDescriptorMatcher.clear

clone

public GenericDescriptorMatcher clone()
Overrides:
clone in class java.lang.Object

clone

public GenericDescriptorMatcher clone(boolean emptyTrainData)

create

public static GenericDescriptorMatcher create(int matcherType)

empty

public boolean empty()

getTrainImages

public java.util.List<Mat> getTrainImages()

Returns a train image collection.

See Also:
org.opencv.features2d.GenericDescriptorMatcher.getTrainImages

getTrainKeypoints

public java.util.List<MatOfKeyPoint> getTrainKeypoints()

Returns a train keypoints collection.

See Also:
org.opencv.features2d.GenericDescriptorMatcher.getTrainKeypoints

isMaskSupported

public boolean isMaskSupported()

Returns true if a generic descriptor matcher supports masking permissible matches.

See Also:
org.opencv.features2d.GenericDescriptorMatcher.isMaskSupported

knnMatch

public void knnMatch(Mat queryImage,
                     MatOfKeyPoint queryKeypoints,
                     java.util.List<MatOfDMatch> matches,
                     int k)

Finds the k best matches for each query keypoint.

The methods are extended variants of GenericDescriptorMatch.match. The parameters are similar, and the semantics is similar to DescriptorMatcher.knnMatch. But this class does not require explicitly computed keypoint descriptors.

Parameters:
queryImage - a queryImage
queryKeypoints - a queryKeypoints
matches - a matches
k - a k
See Also:
org.opencv.features2d.GenericDescriptorMatcher.knnMatch

knnMatch

public void knnMatch(Mat queryImage,
                     MatOfKeyPoint queryKeypoints,
                     java.util.List<MatOfDMatch> matches,
                     int k,
                     java.util.List<Mat> masks,
                     boolean compactResult)

Finds the k best matches for each query keypoint.

The methods are extended variants of GenericDescriptorMatch.match. The parameters are similar, and the semantics is similar to DescriptorMatcher.knnMatch. But this class does not require explicitly computed keypoint descriptors.

Parameters:
queryImage - a queryImage
queryKeypoints - a queryKeypoints
matches - a matches
k - a k
masks - a masks
compactResult - a compactResult
See Also:
org.opencv.features2d.GenericDescriptorMatcher.knnMatch

knnMatch

public void knnMatch(Mat queryImage,
                     MatOfKeyPoint queryKeypoints,
                     Mat trainImage,
                     MatOfKeyPoint trainKeypoints,
                     java.util.List<MatOfDMatch> matches,
                     int k)

Finds the k best matches for each query keypoint.

The methods are extended variants of GenericDescriptorMatch.match. The parameters are similar, and the semantics is similar to DescriptorMatcher.knnMatch. But this class does not require explicitly computed keypoint descriptors.

Parameters:
queryImage - a queryImage
queryKeypoints - a queryKeypoints
trainImage - a trainImage
trainKeypoints - a trainKeypoints
matches - a matches
k - a k
See Also:
org.opencv.features2d.GenericDescriptorMatcher.knnMatch

knnMatch

public void knnMatch(Mat queryImage,
                     MatOfKeyPoint queryKeypoints,
                     Mat trainImage,
                     MatOfKeyPoint trainKeypoints,
                     java.util.List<MatOfDMatch> matches,
                     int k,
                     Mat mask,
                     boolean compactResult)

Finds the k best matches for each query keypoint.

The methods are extended variants of GenericDescriptorMatch.match. The parameters are similar, and the semantics is similar to DescriptorMatcher.knnMatch. But this class does not require explicitly computed keypoint descriptors.

Parameters:
queryImage - a queryImage
queryKeypoints - a queryKeypoints
trainImage - a trainImage
trainKeypoints - a trainKeypoints
matches - a matches
k - a k
mask - a mask
compactResult - a compactResult
See Also:
org.opencv.features2d.GenericDescriptorMatcher.knnMatch

match

public void match(Mat queryImage,
                  MatOfKeyPoint queryKeypoints,
                  Mat trainImage,
                  MatOfKeyPoint trainKeypoints,
                  MatOfDMatch matches)

Finds the best match in the training set for each keypoint from the query set.

The methods find the best match for each query keypoint. In the first variant of the method, a train image and its keypoints are the input arguments. In the second variant, query keypoints are matched to the internally stored training collection that can be built using the GenericDescriptorMatcher.add method. Optional mask (or masks) can be passed to specify which query and training descriptors can be matched. Namely, queryKeypoints[i] can be matched with trainKeypoints[j] only if mask.at(i,j) is non-zero.

Parameters:
queryImage - Query image.
queryKeypoints - Keypoints detected in queryImage.
trainImage - Train image. It is not added to a train image collection stored in the class object.
trainKeypoints - Keypoints detected in trainImage. They are not added to a train points collection stored in the class object.
matches - Matches. If a query descriptor (keypoint) is masked out in mask, match is added for this descriptor. So, matches size may be smaller than the query keypoints count.
See Also:
org.opencv.features2d.GenericDescriptorMatcher.match

match

public void match(Mat queryImage,
                  MatOfKeyPoint queryKeypoints,
                  Mat trainImage,
                  MatOfKeyPoint trainKeypoints,
                  MatOfDMatch matches,
                  Mat mask)

Finds the best match in the training set for each keypoint from the query set.

The methods find the best match for each query keypoint. In the first variant of the method, a train image and its keypoints are the input arguments. In the second variant, query keypoints are matched to the internally stored training collection that can be built using the GenericDescriptorMatcher.add method. Optional mask (or masks) can be passed to specify which query and training descriptors can be matched. Namely, queryKeypoints[i] can be matched with trainKeypoints[j] only if mask.at(i,j) is non-zero.

Parameters:
queryImage - Query image.
queryKeypoints - Keypoints detected in queryImage.
trainImage - Train image. It is not added to a train image collection stored in the class object.
trainKeypoints - Keypoints detected in trainImage. They are not added to a train points collection stored in the class object.
matches - Matches. If a query descriptor (keypoint) is masked out in mask, match is added for this descriptor. So, matches size may be smaller than the query keypoints count.
mask - Mask specifying permissible matches between an input query and train keypoints.
See Also:
org.opencv.features2d.GenericDescriptorMatcher.match

match

public void match(Mat queryImage,
                  MatOfKeyPoint queryKeypoints,
                  MatOfDMatch matches)

Finds the best match in the training set for each keypoint from the query set.

The methods find the best match for each query keypoint. In the first variant of the method, a train image and its keypoints are the input arguments. In the second variant, query keypoints are matched to the internally stored training collection that can be built using the GenericDescriptorMatcher.add method. Optional mask (or masks) can be passed to specify which query and training descriptors can be matched. Namely, queryKeypoints[i] can be matched with trainKeypoints[j] only if mask.at(i,j) is non-zero.

Parameters:
queryImage - Query image.
queryKeypoints - Keypoints detected in queryImage.
matches - Matches. If a query descriptor (keypoint) is masked out in mask, match is added for this descriptor. So, matches size may be smaller than the query keypoints count.
See Also:
org.opencv.features2d.GenericDescriptorMatcher.match

match

public void match(Mat queryImage,
                  MatOfKeyPoint queryKeypoints,
                  MatOfDMatch matches,
                  java.util.List<Mat> masks)

Finds the best match in the training set for each keypoint from the query set.

The methods find the best match for each query keypoint. In the first variant of the method, a train image and its keypoints are the input arguments. In the second variant, query keypoints are matched to the internally stored training collection that can be built using the GenericDescriptorMatcher.add method. Optional mask (or masks) can be passed to specify which query and training descriptors can be matched. Namely, queryKeypoints[i] can be matched with trainKeypoints[j] only if mask.at(i,j) is non-zero.

Parameters:
queryImage - Query image.
queryKeypoints - Keypoints detected in queryImage.
matches - Matches. If a query descriptor (keypoint) is masked out in mask, match is added for this descriptor. So, matches size may be smaller than the query keypoints count.
masks - Set of masks. Each masks[i] specifies permissible matches between input query keypoints and stored train keypoints from the i-th image.
See Also:
org.opencv.features2d.GenericDescriptorMatcher.match

radiusMatch

public void radiusMatch(Mat queryImage,
                        MatOfKeyPoint queryKeypoints,
                        java.util.List<MatOfDMatch> matches,
                        float maxDistance)

For each query keypoint, finds the training keypoints not farther than the specified distance.

The methods are similar to DescriptorMatcher.radius. But this class does not require explicitly computed keypoint descriptors.

Parameters:
queryImage - a queryImage
queryKeypoints - a queryKeypoints
matches - a matches
maxDistance - a maxDistance
See Also:
org.opencv.features2d.GenericDescriptorMatcher.radiusMatch

radiusMatch

public void radiusMatch(Mat queryImage,
                        MatOfKeyPoint queryKeypoints,
                        java.util.List<MatOfDMatch> matches,
                        float maxDistance,
                        java.util.List<Mat> masks,
                        boolean compactResult)

For each query keypoint, finds the training keypoints not farther than the specified distance.

The methods are similar to DescriptorMatcher.radius. But this class does not require explicitly computed keypoint descriptors.

Parameters:
queryImage - a queryImage
queryKeypoints - a queryKeypoints
matches - a matches
maxDistance - a maxDistance
masks - a masks
compactResult - a compactResult
See Also:
org.opencv.features2d.GenericDescriptorMatcher.radiusMatch

radiusMatch

public void radiusMatch(Mat queryImage,
                        MatOfKeyPoint queryKeypoints,
                        Mat trainImage,
                        MatOfKeyPoint trainKeypoints,
                        java.util.List<MatOfDMatch> matches,
                        float maxDistance)

For each query keypoint, finds the training keypoints not farther than the specified distance.

The methods are similar to DescriptorMatcher.radius. But this class does not require explicitly computed keypoint descriptors.

Parameters:
queryImage - a queryImage
queryKeypoints - a queryKeypoints
trainImage - a trainImage
trainKeypoints - a trainKeypoints
matches - a matches
maxDistance - a maxDistance
See Also:
org.opencv.features2d.GenericDescriptorMatcher.radiusMatch

radiusMatch

public void radiusMatch(Mat queryImage,
                        MatOfKeyPoint queryKeypoints,
                        Mat trainImage,
                        MatOfKeyPoint trainKeypoints,
                        java.util.List<MatOfDMatch> matches,
                        float maxDistance,
                        Mat mask,
                        boolean compactResult)

For each query keypoint, finds the training keypoints not farther than the specified distance.

The methods are similar to DescriptorMatcher.radius. But this class does not require explicitly computed keypoint descriptors.

Parameters:
queryImage - a queryImage
queryKeypoints - a queryKeypoints
trainImage - a trainImage
trainKeypoints - a trainKeypoints
matches - a matches
maxDistance - a maxDistance
mask - a mask
compactResult - a compactResult
See Also:
org.opencv.features2d.GenericDescriptorMatcher.radiusMatch

read

public void read(java.lang.String fileName)

Reads a matcher object from a file node.

Parameters:
fileName - a fileName
See Also:
org.opencv.features2d.GenericDescriptorMatcher.read

train

public void train()

Trains descriptor matcher

Prepares descriptor matcher, for example, creates a tree-based structure, to extract descriptors or to optimize descriptors matching.

See Also:
org.opencv.features2d.GenericDescriptorMatcher.train

write

public void write(java.lang.String fileName)

Writes a match object to a file storage.

Parameters:
fileName - a fileName
See Also:
org.opencv.features2d.GenericDescriptorMatcher.write

OpenCV 2.4.8 Documentation