Search in sources :

Example 1 with DogArray_F64

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

the class GenericComputeMeanClustersChecks method checkIdentical.

private void checkIdentical(DogArray<T> clusters1, DogArray<T> clusters2) {
    DogArray_F64 dog1 = new DogArray_F64();
    DogArray_F64 dog2 = new DogArray_F64();
    for (int label = 0; label < numLabels; label++) {
        pointToCommonArray(clusters1.get(label), dog1);
        pointToCommonArray(clusters2.get(label), dog2);
        for (int element = 0; element < dog1.size; element++) {
            assertEquals(dog1.get(element), dog2.get(element), UtilEjml.TEST_F64);
        }
    }
}
Also used : DogArray_F64(org.ddogleg.struct.DogArray_F64)

Example 2 with DogArray_F64

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

the class GenericAssociateGreedyChecks method basic.

@Test
void basic() {
    DogArray<TupleDesc_F64> a = createData(1, 2, 3, 4);
    DogArray<TupleDesc_F64> b = createData(3, 4, 1, 40);
    AssociateGreedyBase<TupleDesc_F64> alg = createAlgorithm();
    alg.setMaxFitError(0.5);
    associate(alg, a, b);
    DogArray_I32 pairs = alg.getPairs();
    assertEquals(2, pairs.get(0));
    assertEquals(-1, pairs.get(1));
    assertEquals(0, pairs.get(2));
    assertEquals(1, pairs.get(3));
    DogArray_F64 fitScore = alg.getFitQuality();
    assertEquals(0, fitScore.get(0), 1e-5);
    assertEquals(0, fitScore.get(2), 1e-5);
    assertEquals(0, fitScore.get(3), 1e-5);
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) DogArray_I32(org.ddogleg.struct.DogArray_I32) DogArray_F64(org.ddogleg.struct.DogArray_F64) Test(org.junit.jupiter.api.Test)

Example 3 with DogArray_F64

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

the class GenericAssociateGreedyChecks method backwards.

@Test
void backwards() {
    DogArray<TupleDesc_F64> a = createData(1, 2, 3, 8);
    DogArray<TupleDesc_F64> b = createData(3, 4, 1, 10);
    AssociateGreedyBase<TupleDesc_F64> alg = createAlgorithm();
    alg.backwardsValidation = true;
    alg.setMaxFitError(10);
    associate(alg, a, b);
    DogArray_I32 pairs = alg.getPairs();
    assertEquals(2, pairs.get(0));
    assertEquals(-1, pairs.get(1));
    assertEquals(0, pairs.get(2));
    assertEquals(3, pairs.get(3));
    DogArray_F64 fitScore = alg.getFitQuality();
    assertEquals(0, fitScore.get(0), 1e-5);
    assertEquals(0, fitScore.get(2), 1e-5);
    assertEquals(2, fitScore.get(3), 1e-5);
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) DogArray_I32(org.ddogleg.struct.DogArray_I32) DogArray_F64(org.ddogleg.struct.DogArray_F64) Test(org.junit.jupiter.api.Test)

Example 4 with DogArray_F64

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

the class TestShapeFittingOps method averageCircle_F64.

@Test
void averageCircle_F64() {
    List<Point2D_F64> points = new ArrayList<>();
    points.add(new Point2D_F64(0, 0));
    points.add(new Point2D_F64(10, 0));
    points.add(new Point2D_F64(5, 5));
    points.add(new Point2D_F64(5, -5));
    FitData<Circle2D_F64> found = ShapeFittingOps.averageCircle_F64(points, null, null);
    assertEquals(5, found.shape.center.x, 1e-5);
    assertEquals(0, found.shape.center.y, 1e-5);
    assertEquals(5, found.shape.radius, 1e-5);
    assertEquals(0, found.error, 1e-5);
    // Pass in storage and see if it fails
    found.error = 23;
    found.shape.center.x = 3;
    DogArray_F64 optional = new DogArray_F64();
    optional.push(4);
    ShapeFittingOps.averageCircle_F64(points, optional, found);
    assertEquals(5, found.shape.center.x, 1e-5);
    assertEquals(0, found.shape.center.y, 1e-5);
    assertEquals(5, found.shape.radius, 1e-5);
    assertEquals(0, found.error, 1e-5);
    // now make it no longer a perfect fit
    points.get(0).x = -1;
    found = ShapeFittingOps.averageCircle_F64(points, null, null);
    assertTrue(found.error > 0);
}
Also used : Circle2D_F64(georegression.struct.trig.Circle2D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) DogArray_F64(org.ddogleg.struct.DogArray_F64) Test(org.junit.jupiter.api.Test)

Example 5 with DogArray_F64

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

the class ImplConvolveBox method vertical.

public static void vertical(GrayF64 input, GrayF64 output, int radius, @Nullable GrowArray<DogArray_F64> workspaces) {
    workspaces = BoofMiscOps.checkDeclare(workspaces, DogArray_F64::new);
    // CONCURRENT_REMOVE_LINE
    final DogArray_F64 work = workspaces.grow();
    final int kernelWidth = radius * 2 + 1;
    final int backStep = kernelWidth * input.stride;
    // CONCURRENT_BELOW BoofConcurrency.loopBlocks(radius, output.height-radius, kernelWidth, workspaces, (work, y0,y1)->{
    final int y0 = radius, y1 = output.height - radius;
    double[] totals = BoofMiscOps.checkDeclare(work, input.width, false);
    for (int x = 0; x < input.width; x++) {
        int indexIn = input.startIndex + (y0 - radius) * input.stride + x;
        int indexOut = output.startIndex + output.stride * y0 + x;
        double total = 0;
        int indexEnd = indexIn + input.stride * kernelWidth;
        for (; indexIn < indexEnd; indexIn += input.stride) {
            total += input.data[indexIn];
        }
        totals[x] = total;
        output.data[indexOut] = total;
    }
    // change the order it is processed in to reduce cache misses
    for (int y = y0 + 1; y < y1; y++) {
        int indexIn = input.startIndex + (y + radius) * input.stride;
        int indexOut = output.startIndex + y * output.stride;
        for (int x = 0; x < input.width; x++, indexIn++, indexOut++) {
            double total = totals[x] - (input.data[indexIn - backStep]);
            totals[x] = total += input.data[indexIn];
            output.data[indexOut] = total;
        }
    }
// CONCURRENT_INLINE });
}
Also used : DogArray_F64(org.ddogleg.struct.DogArray_F64)

Aggregations

DogArray_F64 (org.ddogleg.struct.DogArray_F64)16 Test (org.junit.jupiter.api.Test)5 Circle2D_F64 (georegression.struct.trig.Circle2D_F64)4 DogArray_I32 (org.ddogleg.struct.DogArray_I32)4 ScalePoint (boofcv.struct.feature.ScalePoint)3 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)3 GrayF32 (boofcv.struct.image.GrayF32)3 ArrayList (java.util.ArrayList)3 Point2D_F64 (georegression.struct.point.Point2D_F64)2 Point2D_I32 (georegression.struct.point.Point2D_I32)2 SiftDetector (boofcv.alg.feature.detect.interest.SiftDetector)1 SiftPoint (boofcv.alg.feature.detect.interest.SiftDetector.SiftPoint)1 ConfigFiducialImage (boofcv.factory.fiducial.ConfigFiducialImage)1 ConfigThreshold (boofcv.factory.filter.binary.ConfigThreshold)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 GrayU8 (boofcv.struct.image.GrayU8)1 Point3D_F64 (georegression.struct.point.Point3D_F64)1 BufferedImage (java.awt.image.BufferedImage)1