Search in sources :

Example 11 with FastArray

use of org.ddogleg.struct.FastArray in project BoofCV by lessthanoptimal.

the class TestFeatureSelectUniformBest method checkAllCells.

private void checkAllCells(boolean positive) {
    float largeValue = positive ? 5 : -5;
    // every pixel is a corner
    QueueCorner detected = new QueueCorner();
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            detected.grow().setTo(x, y);
        }
    }
    int cellSize = 10;
    for (int y = 0; y < height; y += cellSize) {
        for (int x = 0; x < width; x += cellSize) {
            intensity.set(x + 2, y + 2, largeValue);
        }
    }
    // this one corner will by far have the most intense features
    for (int y = 0; y < cellSize; y++) {
        for (int x = 0; x < cellSize; x++) {
            intensity.set(x, y, intensity.get(x, y) + largeValue * 4);
        }
    }
    var found = new FastArray<>(Point2D_I16.class);
    FeatureSelectUniformBest<Point2D_I16> alg = createAlgorithm();
    // make it easy to know the cell size
    alg.configUniform = new HackedConfig(cellSize);
    // it should spread out the detections evenly throughout the cells
    checkSpread(positive, detected, cellSize, 1, found, alg);
    // The ones it selects should be the ones with the large values
    for (int y = 0; y < height; y += cellSize) {
        for (int x = 0; x < width; x += cellSize) {
            checkInside(x + 2, y + 2, found);
        }
    }
    checkSpread(positive, detected, cellSize, 2, found, alg);
    // The ones it selects should be the ones with the large values
    for (int y = 0; y < height; y += cellSize) {
        for (int x = 0; x < width; x += cellSize) {
            checkInside(x + 2, y + 2, found);
        }
    }
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner) FastArray(org.ddogleg.struct.FastArray)

Example 12 with FastArray

use of org.ddogleg.struct.FastArray in project BoofCV by lessthanoptimal.

the class HierarchicalVocabularyTree method traverseGraphDepthFirst.

/**
 * Traverses every node in the graph (excluding the root) in a depth first manor.
 *
 * @param op Every node is feed into this function
 */
public void traverseGraphDepthFirst(BoofLambdas.ProcessObject<Node> op) {
    FastArray<Node> queue = new FastArray<>(Node.class, maximumLevel);
    queue.add(nodes.get(0));
    DogArray_I32 branches = new DogArray_I32(maximumLevel);
    branches.add(0);
    if (nodes.get(0).isLeaf())
        return;
    while (!queue.isEmpty()) {
        Node n = queue.getTail();
        int branch = branches.getTail();
        // If there are no more children to traverse in this node go back to the parent
        if (branch >= n.childrenIndexes.size) {
            queue.removeTail();
            branches.removeTail();
            continue;
        }
        // next iteration will explore the next branch
        branches.setTail(0, branch + 1);
        // Pass in the child
        n = nodes.get(n.childrenIndexes.get(branch));
        op.process(n);
        // Can't dive into any children/branches if it's a leaf
        if (n.isLeaf())
            continue;
        queue.add(n);
        branches.add(0);
    }
}
Also used : DogArray_I32(org.ddogleg.struct.DogArray_I32) FastArray(org.ddogleg.struct.FastArray)

Aggregations

FastArray (org.ddogleg.struct.FastArray)12 QueueCorner (boofcv.struct.QueueCorner)6 Point2D_I16 (georegression.struct.point.Point2D_I16)6 Test (org.junit.jupiter.api.Test)6 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)2 ArrayList (java.util.ArrayList)2 DogArray_I32 (org.ddogleg.struct.DogArray_I32)2 SelfCalibrationLinearDualQuadratic (boofcv.alg.geo.selfcalib.SelfCalibrationLinearDualQuadratic)1 Intrinsic (boofcv.alg.geo.selfcalib.SelfCalibrationLinearDualQuadratic.Intrinsic)1 FactoryInterestPoint (boofcv.factory.feature.detect.interest.FactoryInterestPoint)1 CameraPinhole (boofcv.struct.calib.CameraPinhole)1 ElevateViewInfo (boofcv.struct.calib.ElevateViewInfo)1 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)1 GrayF32 (boofcv.struct.image.GrayF32)1 Point2D_F64 (georegression.struct.point.Point2D_F64)1 List (java.util.List)1 DogArray (org.ddogleg.struct.DogArray)1