Package boofcv.alg.scene.nister2006
Class RecognitionVocabularyTreeNister2006<Point>
java.lang.Object
boofcv.alg.scene.nister2006.RecognitionVocabularyTreeNister2006<Point>
- All Implemented Interfaces:
VerbosePrint
Image recognition based off of [1] using inverted files. A
HierarchicalVocabularyTree
is assumed to have
been already trained. When an image is added to the database a TF-IDF descriptor is computed using the tree
and then added to the relevant tree's leaves. When an image is looked up its TF-IDF descriptor is found then
all images in the data base are found that share at least one leaf node. These candidate matches are then
compared against each other and scored using L2-Norm.
Implementation Notes:
This implementation is intended to produce output which is faithful to the original work [1] but has
several modifications internally where there has been an attempt to improve runtime performance, often
at the cost of an increase in memory consumption. A non-exhaustive set of deviations is listed below
- Taking inspiration from [2], this implementation has an explicit representation of the inverted files in non-leaf nodes. This avoid an expensive graph traversal step and replaces it with a very fast array look up.
- Histogram weights are stored in inverted files instead of word counts. Allows more efficient error computation.
[1] Nister, David, and Henrik Stewenius. "Scalable recognition with a vocabulary tree."
2006 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR'06). Vol. 2. Ieee, 2006.
[2] Esteban Uriza, Francisco Gómez Fernández, and Martín Rais, "Efficient Large-scale Image Search With a Vocabulary
Tree", Image Processing On Line, 8 (2018), pp. 71–98
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Used to sum the frequency of words (graph nodes) in the image -
Field Summary
Modifier and TypeFieldDescriptionprotected TupleMapDistanceNorm
Distance between two TF-IDF descriptors.protected final DogArray_I32
Stores a mapping from feature index to leaf IDprotected final DogArray<RecognitionVocabularyTreeNister2006.Frequency>
protected final BigDogArray_I32
List of images added to the databasefinal GrowArray<InvertedFile>
User data associated with each nodeScores for all candidate images which have been sortedIf a node has an inverted file list greater than this amount then it will be skipped when scoring.int
A node can be part of the descriptor if it's at least this far from the root nodeVocabulary Tree -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new image to the database.void
Removes all images from the database.protected void
describe
(List<Point> imageFeatures, DogArray_F32 descWeights, DogArray_I32 descWords) Given the image features, compute a sparse descriptor for the image and pass in leaf nodes to 'op' for each image feature.protected void
findAndScoreMatches
(List<Point> queryImage) Uses the inverted file for each word to create a list of potential matches while scoring the matches efficientlyvoid
Configures the tree by adding LeafData to all the leaves in the tree then saves a reference for future useboolean
query
(List<Point> queryImage, BoofLambdas.FilterInt filter, int limit) Looks up the best BowMatch from the database.void
Used to change distance function to one of the built in typesvoid
setVerbose
(@Nullable PrintStream out, @Nullable Set<String> settings)
-
Field Details
-
tree
Vocabulary Tree -
minimumDepthFromRoot
public int minimumDepthFromRootA node can be part of the descriptor if it's at least this far from the root node -
maximumQueryImagesInNode
If a node has an inverted file list greater than this amount then it will be skipped when scoring. This should be viewed as a last ditch effort when the query is too slow. If there are a 1,000,000 images in the DB, then 20,000 seems to be a reasonable number. -
invertedFiles
User data associated with each node -
imagesDB
List of images added to the database -
matches
Scores for all candidate images which have been sorted -
distanceFunction
Distance between two TF-IDF descriptors. L1 and L2 norms are provided -
featureIdxToLeafID
Stores a mapping from feature index to leaf ID -
frequencies
-
-
Constructor Details
-
RecognitionVocabularyTreeNister2006
public RecognitionVocabularyTreeNister2006()
-
-
Method Details
-
initializeTree
Configures the tree by adding LeafData to all the leaves in the tree then saves a reference for future use- Parameters:
tree
- Three which is to be used as the database. Saved internally.
-
clearImages
public void clearImages()Removes all images from the database. -
addImage
Adds a new image to the database.- Parameters:
imageID
- The image's unique ID for later referenceimageFeatures
- Feature descriptors from an image
-
query
Looks up the best BowMatch from the database. The list of all potential matches can be accessed by calling#getMatches()
.- Parameters:
queryImage
- Set of feature descriptors from the query imagefilter
- Filter which can be used to reject matches that the user doesn't want returned. False = reject.limit
- Maximum number of matches it will return.- Returns:
- The best matching image with score from the database
-
findAndScoreMatches
Uses the inverted file for each word to create a list of potential matches while scoring the matches efficiently -
describe
protected void describe(List<Point> imageFeatures, DogArray_F32 descWeights, DogArray_I32 descWords) Given the image features, compute a sparse descriptor for the image and pass in leaf nodes to 'op' for each image feature.- Parameters:
imageFeatures
- (Input) All image features in the imagedescWeights
- (Output) Weights for non-zero word in TD-IDF descriptor for this imagedescWords
- (Output) Word index for non-zero word in TD-IDF descriptor for this image
-
setDistanceType
Used to change distance function to one of the built in types -
setVerbose
public void setVerbose(@Nullable @Nullable PrintStream out, @Nullable @Nullable Set<String> settings) - Specified by:
setVerbose
in interfaceVerbosePrint
-