Search in sources :

Example 96 with DogArray_I32

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

the class ChecksGenericPointsToPolyline method checkMinVertexes_sequence.

/**
 * Checks to see if this feature can be changed and is enforced
 */
@Test
void checkMinVertexes_sequence() {
    PointsToPolyline alg = createAlg(false);
    alg.setConvex(false);
    alg.setMinimumSides(10);
    List<Point2D_I32> contour = line(0, 0, 30, 0);
    contour.addAll(line(30, 0, 30, 10));
    contour.addAll(line(30, 10, 20, 10));
    contour.addAll(line(20, 10, 20, 30));
    contour.addAll(line(20, 30, 0, 30));
    DogArray_I32 found = new DogArray_I32();
    if (alg.process(contour, found)) {
        assertEquals(9, found.size);
    }
    alg.setMinimumSides(3);
    assertTrue(alg.process(contour, found));
    check(found, 0, 30, 40, 50, 70, 89);
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) DogArray_I32(org.ddogleg.struct.DogArray_I32) Test(org.junit.jupiter.api.Test)

Example 97 with DogArray_I32

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

the class GenericAssociateGreedyChecks method ratioTest.

@Test
void ratioTest() {
    // perfect match is a special case
    // [2] is a very good fit and should pass the ratio test, but is not zero
    DogArray<TupleDesc_F64> a = createData(1, 2, 3, 10);
    DogArray<TupleDesc_F64> b = createData(1, 2, 3.01, 4);
    AssociateGreedyBase<TupleDesc_F64> alg = createAlgorithm();
    // ratio test is turned off by default
    associate(alg, a, b);
    DogArray_I32 pairs = alg.getPairs();
    for (int i = 0; i < 4; i++) {
        assertEquals(i, pairs.get(i));
    }
    // set it so that 4 will be rejected
    alg.setRatioTest(0.1);
    associate(alg, a, b);
    pairs = alg.getPairs();
    assertEquals(0, pairs.get(0));
    assertEquals(1, pairs.get(1));
    assertEquals(2, pairs.get(2));
    assertEquals(-1, pairs.get(3));
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) DogArray_I32(org.ddogleg.struct.DogArray_I32) Test(org.junit.jupiter.api.Test)

Example 98 with DogArray_I32

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

the class ChecksGenericPointsToPolyline method checkIsConvex.

/**
 * Checks to see if this feature can be changed and is enforced
 */
@Test
void checkIsConvex() {
    PointsToPolyline alg = createAlg(true);
    alg.setConvex(true);
    List<Point2D_I32> contour = line(0, 0, 30, 0);
    contour.addAll(line(30, 0, 30, 10));
    contour.addAll(line(30, 10, 20, 10));
    contour.addAll(line(20, 10, 20, 30));
    contour.addAll(line(20, 30, 0, 30));
    contour.addAll(line(0, 30, 0, 0));
    DogArray_I32 found = new DogArray_I32();
    assertFalse(alg.process(contour, found));
    alg.setConvex(false);
    assertTrue(alg.process(contour, found));
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) DogArray_I32(org.ddogleg.struct.DogArray_I32) Test(org.junit.jupiter.api.Test)

Example 99 with DogArray_I32

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

the class ConvolveImageUnrolled_SB_S16_I16_Div method convolve5.

public static void convolve5(Kernel2D_S32 kernel, GrayS16 src, GrayI16 dest, int divisor, @Nullable GrowArray<DogArray_I32> workspaces) {
    workspaces = BoofMiscOps.checkDeclare(workspaces, DogArray_I32::new);
    // CONCURRENT_REMOVE_LINE
    final DogArray_I32 work = workspaces.grow();
    final short[] dataSrc = src.data;
    final short[] dataDst = dest.data;
    final int width = src.getWidth();
    final int height = src.getHeight();
    final int halfDivisor = divisor / 2;
    final int kernelRadius = kernel.getRadius();
    final int kernelWidth = 2 * kernelRadius + 1;
    // CONCURRENT_BELOW BoofConcurrency.loopBlocks(kernelRadius, height-kernelRadius, kernelWidth, workspaces, (work, y0, y1)->{
    final int y0 = kernelRadius, y1 = height - kernelRadius;
    int[] totalRow = BoofMiscOps.checkDeclare(work, src.width, false);
    for (int y = y0; y < y1; y++) {
        // first time through the value needs to be set
        int k1 = kernel.data[0];
        int k2 = kernel.data[1];
        int k3 = kernel.data[2];
        int k4 = kernel.data[3];
        int k5 = kernel.data[4];
        int indexSrcRow = src.startIndex + (y - kernelRadius) * src.stride - kernelRadius;
        for (int x = kernelRadius; x < width - kernelRadius; x++) {
            int indexSrc = indexSrcRow + x;
            int total = 0;
            total += (dataSrc[indexSrc++]) * k1;
            total += (dataSrc[indexSrc++]) * k2;
            total += (dataSrc[indexSrc++]) * k3;
            total += (dataSrc[indexSrc++]) * k4;
            total += (dataSrc[indexSrc]) * k5;
            totalRow[x] = total;
        }
        // rest of the convolution rows are an addition
        for (int i = 1; i < 5; i++) {
            indexSrcRow = src.startIndex + (y + i - kernelRadius) * src.stride - kernelRadius;
            k1 = kernel.data[i * 5 + 0];
            k2 = kernel.data[i * 5 + 1];
            k3 = kernel.data[i * 5 + 2];
            k4 = kernel.data[i * 5 + 3];
            k5 = kernel.data[i * 5 + 4];
            for (int x = kernelRadius; x < width - kernelRadius; x++) {
                int indexSrc = indexSrcRow + x;
                int total = 0;
                total += (dataSrc[indexSrc++]) * k1;
                total += (dataSrc[indexSrc++]) * k2;
                total += (dataSrc[indexSrc++]) * k3;
                total += (dataSrc[indexSrc++]) * k4;
                total += (dataSrc[indexSrc]) * k5;
                totalRow[x] += total;
            }
        }
        int indexDst = dest.startIndex + y * dest.stride + kernelRadius;
        for (int x = kernelRadius; x < width - kernelRadius; x++) {
            dataDst[indexDst++] = (short) ((totalRow[x] + halfDivisor) / divisor);
        }
    }
// CONCURRENT_INLINE });
}
Also used : DogArray_I32(org.ddogleg.struct.DogArray_I32)

Example 100 with DogArray_I32

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

the class ConvolveImageUnrolled_SB_S16_I16_Div method convolve9.

public static void convolve9(Kernel2D_S32 kernel, GrayS16 src, GrayI16 dest, int divisor, @Nullable GrowArray<DogArray_I32> workspaces) {
    workspaces = BoofMiscOps.checkDeclare(workspaces, DogArray_I32::new);
    // CONCURRENT_REMOVE_LINE
    final DogArray_I32 work = workspaces.grow();
    final short[] dataSrc = src.data;
    final short[] dataDst = dest.data;
    final int width = src.getWidth();
    final int height = src.getHeight();
    final int halfDivisor = divisor / 2;
    final int kernelRadius = kernel.getRadius();
    final int kernelWidth = 2 * kernelRadius + 1;
    // CONCURRENT_BELOW BoofConcurrency.loopBlocks(kernelRadius, height-kernelRadius, kernelWidth, workspaces, (work, y0, y1)->{
    final int y0 = kernelRadius, y1 = height - kernelRadius;
    int[] totalRow = BoofMiscOps.checkDeclare(work, src.width, false);
    for (int y = y0; y < y1; y++) {
        // first time through the value needs to be set
        int k1 = kernel.data[0];
        int k2 = kernel.data[1];
        int k3 = kernel.data[2];
        int k4 = kernel.data[3];
        int k5 = kernel.data[4];
        int k6 = kernel.data[5];
        int k7 = kernel.data[6];
        int k8 = kernel.data[7];
        int k9 = kernel.data[8];
        int indexSrcRow = src.startIndex + (y - kernelRadius) * src.stride - kernelRadius;
        for (int x = kernelRadius; x < width - kernelRadius; x++) {
            int indexSrc = indexSrcRow + x;
            int total = 0;
            total += (dataSrc[indexSrc++]) * k1;
            total += (dataSrc[indexSrc++]) * k2;
            total += (dataSrc[indexSrc++]) * k3;
            total += (dataSrc[indexSrc++]) * k4;
            total += (dataSrc[indexSrc++]) * k5;
            total += (dataSrc[indexSrc++]) * k6;
            total += (dataSrc[indexSrc++]) * k7;
            total += (dataSrc[indexSrc++]) * k8;
            total += (dataSrc[indexSrc]) * k9;
            totalRow[x] = total;
        }
        // rest of the convolution rows are an addition
        for (int i = 1; i < 9; i++) {
            indexSrcRow = src.startIndex + (y + i - kernelRadius) * src.stride - kernelRadius;
            k1 = kernel.data[i * 9 + 0];
            k2 = kernel.data[i * 9 + 1];
            k3 = kernel.data[i * 9 + 2];
            k4 = kernel.data[i * 9 + 3];
            k5 = kernel.data[i * 9 + 4];
            k6 = kernel.data[i * 9 + 5];
            k7 = kernel.data[i * 9 + 6];
            k8 = kernel.data[i * 9 + 7];
            k9 = kernel.data[i * 9 + 8];
            for (int x = kernelRadius; x < width - kernelRadius; x++) {
                int indexSrc = indexSrcRow + x;
                int total = 0;
                total += (dataSrc[indexSrc++]) * k1;
                total += (dataSrc[indexSrc++]) * k2;
                total += (dataSrc[indexSrc++]) * k3;
                total += (dataSrc[indexSrc++]) * k4;
                total += (dataSrc[indexSrc++]) * k5;
                total += (dataSrc[indexSrc++]) * k6;
                total += (dataSrc[indexSrc++]) * k7;
                total += (dataSrc[indexSrc++]) * k8;
                total += (dataSrc[indexSrc]) * k9;
                totalRow[x] += total;
            }
        }
        int indexDst = dest.startIndex + y * dest.stride + kernelRadius;
        for (int x = kernelRadius; x < width - kernelRadius; x++) {
            dataDst[indexDst++] = (short) ((totalRow[x] + halfDivisor) / divisor);
        }
    }
// CONCURRENT_INLINE });
}
Also used : DogArray_I32(org.ddogleg.struct.DogArray_I32)

Aggregations

DogArray_I32 (org.ddogleg.struct.DogArray_I32)192 Test (org.junit.jupiter.api.Test)73 Point2D_I32 (georegression.struct.point.Point2D_I32)24 ArrayList (java.util.ArrayList)21 Point2D_F64 (georegression.struct.point.Point2D_F64)17 DogArray (org.ddogleg.struct.DogArray)17 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)15 GrayS32 (boofcv.struct.image.GrayS32)10 VerbosePrint (org.ddogleg.struct.VerbosePrint)7 View (boofcv.alg.structure.PairwiseImageGraph.View)6 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)6 GrayI (boofcv.struct.image.GrayI)5 Point3D_F64 (georegression.struct.point.Point3D_F64)5 GrowArray (pabeles.concurrency.GrowArray)5 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)4 BTrack (boofcv.alg.sfm.d3.structure.VisOdomBundleAdjustment.BTrack)4 AssociatedTripleIndex (boofcv.struct.feature.AssociatedTripleIndex)4 SceneObservations (boofcv.abst.geo.bundle.SceneObservations)3 SceneWorkingGraph (boofcv.alg.structure.SceneWorkingGraph)3 ConfigAssociateGreedy (boofcv.factory.feature.associate.ConfigAssociateGreedy)3