use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.
the class TestSimilarImagesSceneRecognition method simpleAllTogether.
/**
* Simple scenario which exercises everything all at once
*/
@Test
void simpleAllTogether() {
var config = new ConfigSimilarImagesSceneRecognition();
// Needed to do some hacking since the defaults assume there are a bunch of image features
config.minimumSimilar.setRelative(0.1, 0.0);
config.recognizeNister2006.minimumDepthFromRoot = 0;
SimilarImagesSceneRecognition<GrayU8, TupleDesc_F32> alg = FactorySceneReconstruction.createSimilarImages(config, ImageType.SB_U8);
alg.detector = new HelperDetector();
for (int i = 0; i < 5; i++) {
alg.addImage("" + i, new GrayU8(50, 10));
}
alg.fixate();
// For all these other functions just check to see if something got populated
DogArray_I32 words = new DogArray_I32();
alg.lookupImageWords("3", words);
assertTrue(words.size > 0);
var features = new DogArray<>(Point2D_F64::new);
alg.lookupPixelFeats("1", features);
assertTrue(features.size > 0);
// Look up similar images. All but the query view should be similar
List<String> similarImages = new ArrayList<>();
alg.findSimilar("0", (a) -> true, similarImages);
assertTrue(similarImages.size() > 0);
var pairs = new DogArray<>(AssociatedIndex::new);
alg.lookupAssociated(similarImages.get(0), pairs);
assertTrue(features.size > 0);
}
use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.
the class VisOdomBundlePnPBase method performKeyFrameMaintenance.
/**
* Drops specified keyframes from the scene. Returns true if the current frame was dropped
*
* @param tracker tracker
* @param newFrames Number of new frames added to the scene
* @return true if current frame
*/
protected boolean performKeyFrameMaintenance(PointTracker<?> tracker, int newFrames) {
DogArray_I32 dropFrameIndexes = frameManager.selectFramesToDiscard(tracker, maxKeyFrames, newFrames, bundleViso);
boolean droppedCurrentFrame = false;
if (dropFrameIndexes.size != 0) {
droppedCurrentFrame = dropFrameIndexes.getTail(0) == bundleViso.frames.size - 1;
dropFramesFromScene(dropFrameIndexes);
}
dropTracksNotVisibleAndTooFewObservations();
updateListOfVisibleTracksForOutput();
return droppedCurrentFrame;
}
use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.
the class TestTickTockKeyFrameManager method alwaysAddBeforeMax.
@Test
void alwaysAddBeforeMax() {
var tracker = new DummyTracker();
VisOdomBundleAdjustment<BTrack> scene = createScene();
var alg = new TickTockKeyFrameManager();
// don't want it to add a new keyframe right afterwards
alg.keyframePeriod = 10000;
// not used but call it just in case that changes in the future
alg.initialize(scene.cameras);
// add the initial set of frames
for (int i = 0; i < 5; i++) {
DogArray_I32 discard = alg.selectFramesToDiscard(tracker, maxKeyFrames, 1, scene);
assertEquals(0, discard.size);
scene.addFrame(i);
tracker.process(null);
}
// add one more frame. It should now want to discard the current frame
scene.addFrame(6);
tracker.process(null);
DogArray_I32 discard = alg.selectFramesToDiscard(tracker, maxKeyFrames, 1, scene);
assertEquals(1, discard.size);
assertEquals(5, discard.get(0));
}
use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.
the class LearnHierarchicalTree method processLevel.
/**
* Cluster each branch in the tree for the set of points in the node
*
* @param pointsInParent Points that are members of the parent
* @param tree The tree that's being learned
* @param level Level in the HierarchicalVocabularyTree
* @param parentNodeIdx Array index for the parent node
*/
private void processLevel(PackedArray<Point> pointsInParent, HierarchicalVocabularyTree<Point> tree, int level, int parentNodeIdx) {
// Stop here if we are at the maximum number of levels or there are too few points
if (level >= tree.maximumLevel || pointsInParent.size() <= pointsRequiredForChildren)
return;
// Get k-means for this level
StandardKMeans<Point> kmeans = listKMeans.get(level);
// Cluster the input points
kmeans.process(pointsInParent, tree.branchFactor);
DogArray_I32 assignments = kmeans.getAssignments();
List<Point> clusterMeans = kmeans.getBestClusters().toList();
// and this "might" reduce cache misses in searching
for (int label = 0; label < clusterMeans.size(); label++) {
tree.addNode(parentNodeIdx, label, clusterMeans.get(label));
}
if (verbose != null)
verbose.println("level=" + level + " kmeans.score=" + kmeans.getBestClusterScore());
// Load the points that are in the child sub region
Node parent = tree.nodes.get(parentNodeIdx);
// Create pyramid nodes from the children
PackedArray<Point> pointsInBranch = listPoints.get(level);
pointsInBranch.reserve(pointsInParent.size() / (tree.branchFactor - 1));
processChildren(tree, level, parent, pointsInParent, clusterMeans, assignments, pointsInBranch);
}
use of org.ddogleg.struct.DogArray_I32 in project BoofCV by lessthanoptimal.
the class TestReedSolomonCodes_U16 method correctErrors_hand.
/**
* Compare against a hand computed scenario
*/
@Test
void correctErrors_hand() {
DogArray_I16 message = DogArray_I16.parseHex("[ 0x40, 0xd2, 0x75, 0x47, 0x76, 0x17, 0x32, 0x06, 0x27, 0x26, 0x96, 0xc6, 0xc6, 0x96, 0x70, 0xec ]");
var ecc = new DogArray_I16();
DogArray_I16 syndromes = new DogArray_I16();
DogArray_I16 errorLocator = new DogArray_I16();
int nsyn = 10;
var alg = new ReedSolomonCodes_U16(8, primitive8, 0);
alg.generator(nsyn);
alg.computeECC(message, ecc);
DogArray_I16 corrupted = message.copy();
corrupted.data[0] = 0;
corrupted.data[4] = 8;
corrupted.data[5] = 9;
alg.computeSyndromes(corrupted, ecc, syndromes);
alg.findErrorLocatorPolynomialBM(syndromes, errorLocator);
DogArray_I32 errorLocations = new DogArray_I32(3);
errorLocations.data[0] = 0;
errorLocations.data[1] = 4;
errorLocations.data[2] = 5;
errorLocations.size = 3;
alg.correctErrors(corrupted, message.size + ecc.size, syndromes, errorLocator, errorLocations);
assertEquals(corrupted.size, message.size);
for (int j = 0; j < corrupted.size; j++) {
assertEquals(corrupted.get(j), message.get(j));
}
}
Aggregations