Skip to content

Commit

Permalink
Bug Fix
Browse files Browse the repository at this point in the history
- RecognitionVocabularyTreeNister2006 was crashing when empty and clearDatabase() was called.
  • Loading branch information
lessthanoptimal committed Apr 25, 2024
1 parent b6ff12e commit d91c6a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Peter Abeles. All Rights Reserved.
* Copyright (c) 2024, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -127,7 +127,8 @@ public void clearImages() {

// Removes the old leaf data and replaces it with empty structures
invertedFiles.reset();
invertedFiles.resize(tree.nodes.size);
if (tree != null)
invertedFiles.resize(tree.nodes.size);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Peter Abeles. All Rights Reserved.
* Copyright (c) 2024, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -122,6 +122,13 @@ public abstract class GenericFeatureSceneRecognitionChecks<TD extends TupleDesc<
assertFalse(alg.query(getFeatures(1, images), ( id ) -> true, 3, matches));
}

/**
* Test added after a bunch was found where it would blow up if you cleared the database without anything in it
*/
@Test void clearDatabase_empty() {
createAlg().clearDatabase();
}

private FeatureSceneRecognition.Features<TD> getFeatures( int imageIdx, List<List<TD>> images ) {
return new FeatureSceneRecognition.Features<>() {
@Override public Point2D_F64 getPixel( int index ) {
Expand Down

0 comments on commit d91c6a6

Please sign in to comment.