Search in sources :

Example 21 with FastQueue

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

the class TestCombinedTrackerScalePoint method associateAllToDetected.

@Test
public void associateAllToDetected() {
    CombinedTrackerScalePoint alg = new CombinedTrackerScalePoint();
    alg.detectedDesc = new FastQueue(10, BrightFeature.class, false);
    alg.knownDesc = new FastQueue(10, BrightFeature.class, false);
    alg.associate = new DummyAssoc(15);
    alg.detector = new DummyDetector(20);
    alg.trackerKlt = new DummyKlt();
    addTracks(alg.tracksDormant, 3);
    addTracks(alg.tracksReactivated, 4);
    addTracks(alg.tracksPureKlt, 8);
    alg.associateAllToDetected();
    // all dormant should be reactivated
    assertEquals(0, alg.tracksDormant.size());
    assertEquals(7, alg.tracksReactivated.size());
    assertEquals(8, alg.tracksPureKlt.size());
    // make sure the KLT tracks haven't been changed
    for (Object a : alg.tracksPureKlt) {
        CombinedTrack c = (CombinedTrack) a;
        assertEquals(0, c.x, 1e-8);
        assertEquals(0, c.y, 1e-8);
    }
    // the others should have
    for (Object a : alg.tracksReactivated) {
        CombinedTrack c = (CombinedTrack) a;
        assertTrue(0 != c.x);
        assertTrue(0 != c.y);
    }
}
Also used : BrightFeature(boofcv.struct.feature.BrightFeature) FastQueue(org.ddogleg.struct.FastQueue) Test(org.junit.Test)

Example 22 with FastQueue

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

the class TestMergeSmallRegions method process.

/**
 * Runs everything to remove the small patches. This test hsa been designed to take multiple
 * passes to complete.
 */
@Test
public void process() {
    GrayU8 image = new GrayU8(10, 9);
    image.data = new byte[] { 0, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 7, 8, 0, 0, 0, 0, 0, 5, 6, 5, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 7, 0, 0, 0, 5, 5, 4, 4, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 9, 9, 6, 7 };
    GrayS32 pixelToRegion = new GrayS32(10, 9);
    pixelToRegion.data = new int[] { 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 4, 5, 0, 0, 0, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 9, 0, 0, 0, 1, 1, 3, 3, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 6, 6, 7, 8 };
    GrowQueue_I32 memberCount = new GrowQueue_I32();
    memberCount.resize(10);
    for (int i = 0; i < pixelToRegion.data.length; i++) {
        memberCount.data[pixelToRegion.data[i]]++;
    }
    FastQueue<float[]> regionColor = new FastQueue<float[]>(float[].class, true) {

        protected float[] createInstance() {
            return new float[1];
        }
    };
    regionColor.resize(10);
    ComputeRegionMeanColor<GrayU8> mean = new ComputeRegionMeanColor.U8();
    mean.process(image, pixelToRegion, memberCount, regionColor);
    MergeSmallRegions<GrayU8> alg = new MergeSmallRegions<>(3, ConnectRule.FOUR, mean);
    alg.process(image, pixelToRegion, memberCount, regionColor);
    // check the results.  Should only be three regions
    assertEquals(3, memberCount.size);
    assertEquals(3, regionColor.size);
    GrowQueue_I32 memberExpected = new GrowQueue_I32(3);
    memberExpected.resize(3);
    for (int i = 0; i < pixelToRegion.data.length; i++) {
        memberExpected.data[pixelToRegion.data[i]]++;
    }
    for (int i = 0; i < 3; i++) assertEquals(memberExpected.get(i), memberCount.get(i));
    // simple sanity check
    assertTrue(memberExpected.get(0) > memberExpected.get(1));
}
Also used : GrayU8(boofcv.struct.image.GrayU8) FastQueue(org.ddogleg.struct.FastQueue) GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 23 with FastQueue

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

the class GenericFhEdgeWeightsChecks method subimage.

@Test
public void subimage() {
    T input = imageType.createImage(10, 12);
    GImageMiscOps.fillUniform(input, rand, 0, 200);
    T inputSub = BoofTesting.createSubImageOf(input);
    FhEdgeWeights<T> alg = createAlg();
    FastQueue<Edge> edges0 = new FastQueue<>(Edge.class, true);
    FastQueue<Edge> edges1 = new FastQueue<>(Edge.class, true);
    alg.process(input, edges0);
    alg.process(inputSub, edges1);
    // both should be identical
    assertEquals(edges0.size, edges1.size);
    for (int i = 0; i < edges0.size; i++) {
        Edge e0 = edges0.get(i);
        Edge e1 = edges1.get(i);
        assertEquals("i = " + i, e0.indexA, e1.indexA);
        assertEquals("i = " + i, e0.indexB, e1.indexB);
        assertEquals("i = " + i, e0.sortValue, e1.sortValue, 1e-4f);
    }
}
Also used : FastQueue(org.ddogleg.struct.FastQueue) Edge(boofcv.alg.segmentation.fh04.SegmentFelzenszwalbHuttenlocher04.Edge) Test(org.junit.Test)

Example 24 with FastQueue

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

the class TestPnPLepetitEPnP method computeBarycentricCoordinates.

@Test
public void computeBarycentricCoordinates() {
    List<Point3D_F64> worldPoints = GeoTestingOps.randomPoints_F64(-1, 10, -5, 20, 0.1, 0.5, 30, rand);
    FastQueue<Point3D_F64> worldControlPts = new FastQueue<>(4, Point3D_F64.class, true);
    PnPLepetitEPnP alg = new PnPLepetitEPnP();
    alg.selectWorldControlPoints(worldPoints, worldControlPts);
    DMatrixRMaj alpha = new DMatrixRMaj(1, 1);
    alg.computeBarycentricCoordinates(worldControlPts, alpha, worldPoints);
    // make sure it sums up to one and it should add up to the original point
    for (int i = 0; i < worldPoints.size(); i++) {
        double x = 0, y = 0, z = 0;
        double sum = 0;
        for (int j = 0; j < 4; j++) {
            Point3D_F64 cj = worldControlPts.get(j);
            double a = alpha.get(i, j);
            sum += a;
            x += a * cj.x;
            y += a * cj.y;
            z += a * cj.z;
        }
        Point3D_F64 p = worldPoints.get(i);
        assertEquals(1, sum, 1e-8);
        assertEquals(p.x, x, 1e-8);
        assertEquals(p.y, y, 1e-8);
        assertEquals(p.z, z, 1e-8);
    }
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) FastQueue(org.ddogleg.struct.FastQueue) DMatrixRMaj(org.ejml.data.DMatrixRMaj) Test(org.junit.Test)

Example 25 with FastQueue

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

the class TestRelinearlize method createInputs.

private void createInputs(int numControl) {
    if (numControl == 4) {
        L_full = new DMatrixRMaj(6, 10);
        y = new DMatrixRMaj(6, 1);
    } else {
        L_full = new DMatrixRMaj(3, 6);
        y = new DMatrixRMaj(3, 1);
    }
    // randomly select null points,
    List<Point3D_F64>[] nullPts = new ArrayList[numControl];
    for (int i = 0; i < numControl - 1; i++) {
        nullPts[i] = GeoTestingOps.randomPoints_F64(-1, 1, -1, 1, -1, 1, numControl, rand);
    }
    nullPts[numControl - 1] = new ArrayList<>();
    nullPts[numControl - 1].add(new Point3D_F64(1, 0, 0));
    nullPts[numControl - 1].add(new Point3D_F64(0, 1, 0));
    nullPts[numControl - 1].add(new Point3D_F64(0, 0, 1));
    if (numControl == 4)
        nullPts[numControl - 1].add(new Point3D_F64(0, 0, 0));
    // using the provided beta compute the world points
    // this way the constraint matrix will be consistent
    FastQueue<Point3D_F64> worldPts = new FastQueue<>(4, Point3D_F64.class, true);
    worldPts.grow().set(1, 0, 0);
    worldPts.grow().set(0, 1, 0);
    worldPts.grow().set(0, 0, 1);
    if (numControl == 4)
        worldPts.grow().set(0, 0, 0);
    if (numControl == 4)
        UtilLepetitEPnP.constraintMatrix6x10(L_full, y, worldPts, nullPts);
    else
        UtilLepetitEPnP.constraintMatrix3x6(L_full, y, worldPts, nullPts);
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) FastQueue(org.ddogleg.struct.FastQueue) DMatrixRMaj(org.ejml.data.DMatrixRMaj) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

FastQueue (org.ddogleg.struct.FastQueue)27 Test (org.junit.Test)17 Point3D_F64 (georegression.struct.point.Point3D_F64)9 GrayU16 (boofcv.struct.image.GrayU16)5 GrayU8 (boofcv.struct.image.GrayU8)5 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)5 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)4 FastQueueArray_I32 (boofcv.struct.FastQueueArray_I32)4 Point2D_F64 (georegression.struct.point.Point2D_F64)4 Point2D_I32 (georegression.struct.point.Point2D_I32)4 BufferedImage (java.awt.image.BufferedImage)4 ArrayList (java.util.ArrayList)4 DMatrixRMaj (org.ejml.data.DMatrixRMaj)4 BrightFeature (boofcv.struct.feature.BrightFeature)3 GrayS32 (boofcv.struct.image.GrayS32)3 File (java.io.File)3 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)2 Edge (boofcv.alg.segmentation.fh04.SegmentFelzenszwalbHuttenlocher04.Edge)2 PointCloudViewer (boofcv.gui.d3.PointCloudViewer)2 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)2