Package boofcv.abst.scene.ann
Class FeatureSceneRecognitionNearestNeighbor<TD extends TupleDesc<TD>>
java.lang.Object
boofcv.abst.scene.ann.FeatureSceneRecognitionNearestNeighbor<TD>
- All Implemented Interfaces:
FeatureSceneRecognition<TD>
,VerbosePrint
public class FeatureSceneRecognitionNearestNeighbor<TD extends TupleDesc<TD>>
extends Object
implements FeatureSceneRecognition<TD>
Wrapper around
RecognitionNearestNeighborInvertedFile
for FeatureSceneRecognition
.-
Nested Class Summary
Nested classes/interfaces inherited from interface boofcv.abst.scene.FeatureSceneRecognition
FeatureSceneRecognition.Features<TD extends TupleDesc<TD>>
-
Field Summary
-
Constructor Summary
ConstructorDescriptionFeatureSceneRecognitionNearestNeighbor
(ConfigRecognitionNearestNeighbor config, Factory<TD> factory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addImage
(String id, FeatureSceneRecognition.Features<TD> features) Adds a new image to the databasevoid
Removes all images from the database.The image data type which can be processedgetImageIds
(@Nullable List<String> storage) Returns a list of image IDs in the databaseint
getQueryWord
(int featureIdx) Returns a single word which describes this image feature.void
getQueryWords
(int featureIdx, DogArray_I32 words) Used to retrieve all the words a feature is associated with.int
Returns the number of unique words.void
learnModel
(Iterator<FeatureSceneRecognition.Features<TD>> images) Learns a model using the already extracted image featuresint
lookupWord
(TD description) void
lookupWords
(TD description, DogArray_I32 words) boolean
query
(FeatureSceneRecognition.Features<TD> query, @Nullable BoofLambdas.Filter<String> filter, int limit, DogArray<SceneRecognition.Match> matches) Finds the best matches in the database to the query image.void
setDictionary
(List<TD> dictionary) Replaces the old dictionary with the new dictionary.void
setVerbose
(@Nullable PrintStream out, @Nullable Set<String> config)
-
Field Details
-
minimumForThread
public int minimumForThreadPerformance tuning. If less than this number of features a single thread algorithm will be used
-
-
Constructor Details
-
FeatureSceneRecognitionNearestNeighbor
public FeatureSceneRecognitionNearestNeighbor(ConfigRecognitionNearestNeighbor config, Factory<TD> factory)
-
-
Method Details
-
learnModel
Description copied from interface:FeatureSceneRecognition
Learns a model using the already extracted image features- Specified by:
learnModel
in interfaceFeatureSceneRecognition<TD extends TupleDesc<TD>>
-
clearDatabase
public void clearDatabase()Description copied from interface:FeatureSceneRecognition
Removes all images from the database. The model is not modified- Specified by:
clearDatabase
in interfaceFeatureSceneRecognition<TD extends TupleDesc<TD>>
-
addImage
Description copied from interface:FeatureSceneRecognition
Adds a new image to the database- Specified by:
addImage
in interfaceFeatureSceneRecognition<TD extends TupleDesc<TD>>
- Parameters:
id
- The unique ID for this imagefeatures
- All the features in this image
-
getImageIds
Description copied from interface:FeatureSceneRecognition
Returns a list of image IDs in the database- Specified by:
getImageIds
in interfaceFeatureSceneRecognition<TD extends TupleDesc<TD>>
- Parameters:
storage
- (Optional) Storage for the list of images. If null a new instance is created- Returns:
- List of all the image IDs.
-
query
public boolean query(FeatureSceneRecognition.Features<TD> query, @Nullable BoofLambdas.Filter<String> filter, int limit, DogArray<SceneRecognition.Match> matches) Description copied from interface:FeatureSceneRecognition
Finds the best matches in the database to the query image. The filter can (optionally) be used to remove matches which are not of interest, i.e. too close in time.- Specified by:
query
in interfaceFeatureSceneRecognition<TD extends TupleDesc<TD>>
- Parameters:
query
- (Input) Features in the query imagefilter
- (Input) Filter results by ID. true = keep, false = reject. Null means no filter.limit
- (Input) The maximum number of results it will return. If ≤ 0 then all matches are returned.matches
- (Output) Set of matches found in best first order. List is always cleared- Returns:
- true if at least one valid match was found or false if no valid matches could be found. If false that means matches is empty. This is strictly a convenience.
-
setDictionary
Replaces the old dictionary with the new dictionary.- Parameters:
dictionary
- Dictionary of words
-
getQueryWord
public int getQueryWord(int featureIdx) Description copied from interface:FeatureSceneRecognition
Returns a single word which describes this image feature. If multiple words describe a feature in its internal implementation then there is some ambiguity resolving logic.- Specified by:
getQueryWord
in interfaceFeatureSceneRecognition<TD extends TupleDesc<TD>>
- Parameters:
featureIdx
- (Input) Index of the feature in the query.- Returns:
- The word's ID. If no word is associated with this feature then -1 is returned.
-
getQueryWords
Description copied from interface:FeatureSceneRecognition
Used to retrieve all the words a feature is associated with. If the internal implementation is hierarchical then words it passes through on the way a leaf could go in the words list.- Specified by:
getQueryWords
in interfaceFeatureSceneRecognition<TD extends TupleDesc<TD>>
- Parameters:
featureIdx
- (Input) Index of the feature in the query.words
- (Output) Storage for all the words the feature is associated with
-
lookupWord
- Specified by:
lookupWord
in interfaceFeatureSceneRecognition<TD extends TupleDesc<TD>>
-
lookupWords
- Specified by:
lookupWords
in interfaceFeatureSceneRecognition<TD extends TupleDesc<TD>>
-
getTotalWords
public int getTotalWords()Description copied from interface:FeatureSceneRecognition
Returns the number of unique words. it's assumed that the word ID's will occupy 0 to this value.- Specified by:
getTotalWords
in interfaceFeatureSceneRecognition<TD extends TupleDesc<TD>>
-
getDescriptorType
Description copied from interface:FeatureSceneRecognition
The image data type which can be processed- Specified by:
getDescriptorType
in interfaceFeatureSceneRecognition<TD extends TupleDesc<TD>>
-
setVerbose
- Specified by:
setVerbose
in interfaceVerbosePrint
-