Class AssociateNearestNeighbor<D>

java.lang.Object
boofcv.alg.feature.associate.AssociateNearestNeighbor<D>
All Implemented Interfaces:
Associate<D>, AssociateDescription<D>
Direct Known Subclasses:
AssociateNearestNeighbor_MT, AssociateNearestNeighbor_ST

public abstract class AssociateNearestNeighbor<D> extends Object implements AssociateDescription<D>

Matches features using a NearestNeighbor search from DDogleg. The source features are processed as a lump using NearestNeighbor.setPoints(List, boolean) while destination features are matched one at time using NearestNeighbor.Search.findNearest(Object, double, NnData). Typically the processing of source features is more expensive and should be minimized while looking up destination features is fast. Multiple matches for source features are possible while there will only be a unique match for each destination feature.

An optional ratio test inspired from [1] can be used. The ratio between the best and second best score is found. if the difference is significant enough then the match is accepted. This this is a ratio test, knowing if the score is squared is important. Please set the flag correctly. Almost always the score is Euclidean distance squared.

[1] Lowe, David G. "Distinctive image features from scale-invariant keypoints." International journal of computer vision 60.2 (2004): 91-110.

  • Field Details

  • Constructor Details

    • AssociateNearestNeighbor

      protected AssociateNearestNeighbor(NearestNeighbor<D> alg)
  • Method Details

    • setSource

      public void setSource(FastAccess<D> listSrc)
      Description copied from interface: AssociateDescription
      Sets the list of source features. NOTE: A reference to the input list might be saved internally until the next call to this function.
      Specified by:
      setSource in interface AssociateDescription<D>
      Parameters:
      listSrc - List of features
    • setDestination

      public void setDestination(FastAccess<D> listDst)
      Description copied from interface: AssociateDescription
      Sets the list of destination features NOTE: A reference to the input list might be saved internally until the next call to this function.
      Specified by:
      setDestination in interface AssociateDescription<D>
      Parameters:
      listDst - List of features
    • getMatches

      public DogArray<AssociatedIndex> getMatches()
      Description copied from interface: Associate
      List of associated features. Indexes refer to the index inside the input lists.
      Specified by:
      getMatches in interface Associate<D>
      Returns:
      List of associated features.
    • getUnassociatedSource

      public DogArray_I32 getUnassociatedSource()
      Description copied from interface: Associate
      Indexes of features in the source set which are not associated. WARNING: In some implementations the unassociated list is recomputed each time this function is invoked. In other implementations it was found virtually for free while the matches are found.
      Specified by:
      getUnassociatedSource in interface Associate<D>
      Returns:
      List of unassociated source features by index.
    • getUnassociatedDestination

      public DogArray_I32 getUnassociatedDestination()
      Description copied from interface: Associate
      Indexes of features in the destination set which are not associated. WARNING: In some implementations the unassociated list is recomputed each time this function is invoked. In other implementations it was found virtually for free while the matches are found.
      Specified by:
      getUnassociatedDestination in interface Associate<D>
      Returns:
      List of unassociated destination features by index.
    • setMaxScoreThreshold

      public void setMaxScoreThreshold(double score)
      Description copied from interface: Associate
      Associations are only considered if their score is less than or equal to the specified threshold. To remove any threshold test set this value to Double.MAX_VALUE
      Specified by:
      setMaxScoreThreshold in interface Associate<D>
      Parameters:
      score - The threshold.
    • getScoreType

      public MatchScoreType getScoreType()
      Description copied from interface: Associate
      Specifies the type of score which is returned.
      Specified by:
      getScoreType in interface Associate<D>
      Returns:
      Type of association score.
    • uniqueSource

      public boolean uniqueSource()
      Description copied from interface: Associate
      If at most one match is returned for each source feature.
      Specified by:
      uniqueSource in interface Associate<D>
      Returns:
      true for unique source association
    • uniqueDestination

      public boolean uniqueDestination()
      Description copied from interface: Associate
      If at most one match is returned for each destination feature.
      Specified by:
      uniqueDestination in interface Associate<D>
      Returns:
      true for unique destination association
    • isRatioUsesSqrt

      public boolean isRatioUsesSqrt()
    • setRatioUsesSqrt

      public void setRatioUsesSqrt(boolean ratioUsesSqrt)
    • getScoreRatioThreshold

      public double getScoreRatioThreshold()
    • setScoreRatioThreshold

      public void setScoreRatioThreshold(double scoreRatioThreshold)