OpenCV 2.4.11

org.opencv.features2d

Class DescriptorMatcher

    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void add(java.util.List<Mat> descriptors)
      Adds descriptors to train a descriptor collection.
      void clear()
      Clears the train descriptor collection.
      DescriptorMatcher clone() 
      DescriptorMatcher clone(boolean emptyTrainData) 
      static DescriptorMatcher create(int matcherType)
      Creates a descriptor matcher of a given type with the default parameters (using default constructor).
      boolean empty()
      Returns true if there are no train descriptors in the collection.
      java.util.List<Mat> getTrainDescriptors()
      Returns a constant link to the train descriptor collection trainDescCollection.
      boolean isMaskSupported()
      Returns true if the descriptor matcher supports masking permissible matches.
      void knnMatch(Mat queryDescriptors, java.util.List<MatOfDMatch> matches, int k)
      Finds the k best matches for each descriptor from a query set.
      void knnMatch(Mat queryDescriptors, java.util.List<MatOfDMatch> matches, int k, java.util.List<Mat> masks, boolean compactResult)
      Finds the k best matches for each descriptor from a query set.
      void knnMatch(Mat queryDescriptors, Mat trainDescriptors, java.util.List<MatOfDMatch> matches, int k)
      Finds the k best matches for each descriptor from a query set.
      void knnMatch(Mat queryDescriptors, Mat trainDescriptors, java.util.List<MatOfDMatch> matches, int k, Mat mask, boolean compactResult)
      Finds the k best matches for each descriptor from a query set.
      void match(Mat queryDescriptors, Mat trainDescriptors, MatOfDMatch matches)
      Finds the best match for each descriptor from a query set.
      void match(Mat queryDescriptors, Mat trainDescriptors, MatOfDMatch matches, Mat mask)
      Finds the best match for each descriptor from a query set.
      void match(Mat queryDescriptors, MatOfDMatch matches)
      Finds the best match for each descriptor from a query set.
      void match(Mat queryDescriptors, MatOfDMatch matches, java.util.List<Mat> masks)
      Finds the best match for each descriptor from a query set.
      void radiusMatch(Mat queryDescriptors, java.util.List<MatOfDMatch> matches, float maxDistance)
      For each query descriptor, finds the training descriptors not farther than the specified distance.
      void radiusMatch(Mat queryDescriptors, java.util.List<MatOfDMatch> matches, float maxDistance, java.util.List<Mat> masks, boolean compactResult)
      For each query descriptor, finds the training descriptors not farther than the specified distance.
      void radiusMatch(Mat queryDescriptors, Mat trainDescriptors, java.util.List<MatOfDMatch> matches, float maxDistance)
      For each query descriptor, finds the training descriptors not farther than the specified distance.
      void radiusMatch(Mat queryDescriptors, Mat trainDescriptors, java.util.List<MatOfDMatch> matches, float maxDistance, Mat mask, boolean compactResult)
      For each query descriptor, finds the training descriptors not farther than the specified distance.
      void read(java.lang.String fileName) 
      void train()
      Trains a descriptor matcher
      void write(java.lang.String fileName) 
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • add

        public void add(java.util.List<Mat> descriptors)

        Adds descriptors to train a descriptor collection. If the collection trainDescCollectionis is not empty, the new descriptors are added to existing train descriptors.

        Parameters:
        descriptors - Descriptors to add. Each descriptors[i] is a set of descriptors from the same train image.
        See Also:
        org.opencv.features2d.DescriptorMatcher.add
      • clone

        public DescriptorMatcher clone()
        Overrides:
        clone in class java.lang.Object
      • knnMatch

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

        Finds the k best matches for each descriptor from a query set.

        These extended variants of "DescriptorMatcher.match" methods find several best matches for each query descriptor. The matches are returned in the distance increasing order. See "DescriptorMatcher.match" for the details about query and train descriptors.

        Parameters:
        queryDescriptors - Query set of descriptors.
        matches - Matches. Each matches[i] is k or less matches for the same query descriptor.
        k - Count of best matches found per each query descriptor or less if a query descriptor has less than k possible matches in total.
        See Also:
        org.opencv.features2d.DescriptorMatcher.knnMatch
      • knnMatch

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

        Finds the k best matches for each descriptor from a query set.

        These extended variants of "DescriptorMatcher.match" methods find several best matches for each query descriptor. The matches are returned in the distance increasing order. See "DescriptorMatcher.match" for the details about query and train descriptors.

        Parameters:
        queryDescriptors - Query set of descriptors.
        matches - Matches. Each matches[i] is k or less matches for the same query descriptor.
        k - Count of best matches found per each query descriptor or less if a query descriptor has less than k possible matches in total.
        masks - Set of masks. Each masks[i] specifies permissible matches between the input query descriptors and stored train descriptors from the i-th image trainDescCollection[i].
        compactResult - Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.
        See Also:
        org.opencv.features2d.DescriptorMatcher.knnMatch
      • knnMatch

        public void knnMatch(Mat queryDescriptors,
                    Mat trainDescriptors,
                    java.util.List<MatOfDMatch> matches,
                    int k)

        Finds the k best matches for each descriptor from a query set.

        These extended variants of "DescriptorMatcher.match" methods find several best matches for each query descriptor. The matches are returned in the distance increasing order. See "DescriptorMatcher.match" for the details about query and train descriptors.

        Parameters:
        queryDescriptors - Query set of descriptors.
        trainDescriptors - Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.
        matches - Matches. Each matches[i] is k or less matches for the same query descriptor.
        k - Count of best matches found per each query descriptor or less if a query descriptor has less than k possible matches in total.
        See Also:
        org.opencv.features2d.DescriptorMatcher.knnMatch
      • knnMatch

        public void knnMatch(Mat queryDescriptors,
                    Mat trainDescriptors,
                    java.util.List<MatOfDMatch> matches,
                    int k,
                    Mat mask,
                    boolean compactResult)

        Finds the k best matches for each descriptor from a query set.

        These extended variants of "DescriptorMatcher.match" methods find several best matches for each query descriptor. The matches are returned in the distance increasing order. See "DescriptorMatcher.match" for the details about query and train descriptors.

        Parameters:
        queryDescriptors - Query set of descriptors.
        trainDescriptors - Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.
        matches - Matches. Each matches[i] is k or less matches for the same query descriptor.
        k - Count of best matches found per each query descriptor or less if a query descriptor has less than k possible matches in total.
        mask - Mask specifying permissible matches between an input query and train matrices of descriptors.
        compactResult - Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.
        See Also:
        org.opencv.features2d.DescriptorMatcher.knnMatch
      • match

        public void match(Mat queryDescriptors,
                 Mat trainDescriptors,
                 MatOfDMatch matches)

        Finds the best match for each descriptor from a query set.

        In the first variant of this method, the train descriptors are passed as an input argument. In the second variant of the method, train descriptors collection that was set by DescriptorMatcher.add is used. Optional mask (or masks) can be passed to specify which query and training descriptors can be matched. Namely, queryDescriptors[i] can be matched with trainDescriptors[j] only if mask.at(i,j) is non-zero.

        Parameters:
        queryDescriptors - Query set of descriptors.
        trainDescriptors - Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.
        matches - Matches. If a query descriptor is masked out in mask, no match is added for this descriptor. So, matches size may be smaller than the query descriptors count.
        See Also:
        org.opencv.features2d.DescriptorMatcher.match
      • match

        public void match(Mat queryDescriptors,
                 Mat trainDescriptors,
                 MatOfDMatch matches,
                 Mat mask)

        Finds the best match for each descriptor from a query set.

        In the first variant of this method, the train descriptors are passed as an input argument. In the second variant of the method, train descriptors collection that was set by DescriptorMatcher.add is used. Optional mask (or masks) can be passed to specify which query and training descriptors can be matched. Namely, queryDescriptors[i] can be matched with trainDescriptors[j] only if mask.at(i,j) is non-zero.

        Parameters:
        queryDescriptors - Query set of descriptors.
        trainDescriptors - Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.
        matches - Matches. If a query descriptor is masked out in mask, no match is added for this descriptor. So, matches size may be smaller than the query descriptors count.
        mask - Mask specifying permissible matches between an input query and train matrices of descriptors.
        See Also:
        org.opencv.features2d.DescriptorMatcher.match
      • match

        public void match(Mat queryDescriptors,
                 MatOfDMatch matches)

        Finds the best match for each descriptor from a query set.

        In the first variant of this method, the train descriptors are passed as an input argument. In the second variant of the method, train descriptors collection that was set by DescriptorMatcher.add is used. Optional mask (or masks) can be passed to specify which query and training descriptors can be matched. Namely, queryDescriptors[i] can be matched with trainDescriptors[j] only if mask.at(i,j) is non-zero.

        Parameters:
        queryDescriptors - Query set of descriptors.
        matches - Matches. If a query descriptor is masked out in mask, no match is added for this descriptor. So, matches size may be smaller than the query descriptors count.
        See Also:
        org.opencv.features2d.DescriptorMatcher.match
      • match

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

        Finds the best match for each descriptor from a query set.

        In the first variant of this method, the train descriptors are passed as an input argument. In the second variant of the method, train descriptors collection that was set by DescriptorMatcher.add is used. Optional mask (or masks) can be passed to specify which query and training descriptors can be matched. Namely, queryDescriptors[i] can be matched with trainDescriptors[j] only if mask.at(i,j) is non-zero.

        Parameters:
        queryDescriptors - Query set of descriptors.
        matches - Matches. If a query descriptor is masked out in mask, no match is added for this descriptor. So, matches size may be smaller than the query descriptors count.
        masks - Set of masks. Each masks[i] specifies permissible matches between the input query descriptors and stored train descriptors from the i-th image trainDescCollection[i].
        See Also:
        org.opencv.features2d.DescriptorMatcher.match
      • radiusMatch

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

        For each query descriptor, finds the training descriptors not farther than the specified distance.

        For each query descriptor, the methods find such training descriptors that the distance between the query descriptor and the training descriptor is equal or smaller than maxDistance. Found matches are returned in the distance increasing order.

        Parameters:
        queryDescriptors - Query set of descriptors.
        matches - Found matches.
        maxDistance - Threshold for the distance between matched descriptors. Distance means here metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured in Pixels)!
        See Also:
        org.opencv.features2d.DescriptorMatcher.radiusMatch
      • radiusMatch

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

        For each query descriptor, finds the training descriptors not farther than the specified distance.

        For each query descriptor, the methods find such training descriptors that the distance between the query descriptor and the training descriptor is equal or smaller than maxDistance. Found matches are returned in the distance increasing order.

        Parameters:
        queryDescriptors - Query set of descriptors.
        matches - Found matches.
        maxDistance - Threshold for the distance between matched descriptors. Distance means here metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured in Pixels)!
        masks - Set of masks. Each masks[i] specifies permissible matches between the input query descriptors and stored train descriptors from the i-th image trainDescCollection[i].
        compactResult - Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.
        See Also:
        org.opencv.features2d.DescriptorMatcher.radiusMatch
      • radiusMatch

        public void radiusMatch(Mat queryDescriptors,
                       Mat trainDescriptors,
                       java.util.List<MatOfDMatch> matches,
                       float maxDistance)

        For each query descriptor, finds the training descriptors not farther than the specified distance.

        For each query descriptor, the methods find such training descriptors that the distance between the query descriptor and the training descriptor is equal or smaller than maxDistance. Found matches are returned in the distance increasing order.

        Parameters:
        queryDescriptors - Query set of descriptors.
        trainDescriptors - Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.
        matches - Found matches.
        maxDistance - Threshold for the distance between matched descriptors. Distance means here metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured in Pixels)!
        See Also:
        org.opencv.features2d.DescriptorMatcher.radiusMatch
      • radiusMatch

        public void radiusMatch(Mat queryDescriptors,
                       Mat trainDescriptors,
                       java.util.List<MatOfDMatch> matches,
                       float maxDistance,
                       Mat mask,
                       boolean compactResult)

        For each query descriptor, finds the training descriptors not farther than the specified distance.

        For each query descriptor, the methods find such training descriptors that the distance between the query descriptor and the training descriptor is equal or smaller than maxDistance. Found matches are returned in the distance increasing order.

        Parameters:
        queryDescriptors - Query set of descriptors.
        trainDescriptors - Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.
        matches - Found matches.
        maxDistance - Threshold for the distance between matched descriptors. Distance means here metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured in Pixels)!
        mask - Mask specifying permissible matches between an input query and train matrices of descriptors.
        compactResult - Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.
        See Also:
        org.opencv.features2d.DescriptorMatcher.radiusMatch
      • read

        public void read(java.lang.String fileName)
      • train

        public void train()

        Trains a descriptor matcher

        Trains a descriptor matcher (for example, the flann index). In all methods to match, the method train() is run every time before matching. Some descriptor matchers (for example, BruteForceMatcher) have an empty implementation of this method. Other matchers really train their inner structures (for example, FlannBasedMatcher trains flann.Index).

        See Also:
        org.opencv.features2d.DescriptorMatcher.train
      • write

        public void write(java.lang.String fileName)