Search in sources :

Example 56 with DogArray

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

the class GenericFhEdgeWeightsChecks method subimage.

@Test
void subimage() {
    T input = imageType.createImage(10, 12);
    GImageMiscOps.fillUniform(input, rand, 0, 200);
    T inputSub = BoofTesting.createSubImageOf(input);
    FhEdgeWeights<T> alg = createAlg();
    DogArray<Edge> edges0 = new DogArray<>(Edge::new);
    DogArray<Edge> edges1 = new DogArray<>(Edge::new);
    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(e0.indexA, e1.indexA);
        assertEquals(e0.indexB, e1.indexB);
        assertEquals(e0.sortValue, e1.sortValue, 1e-4f);
    }
}
Also used : Edge(boofcv.alg.segmentation.fh04.SegmentFelzenszwalbHuttenlocher04.Edge) DogArray(org.ddogleg.struct.DogArray) Test(org.junit.jupiter.api.Test)

Example 57 with DogArray

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

the class CommonProjectiveToMetricCamerasChecks method real_world_case0.

/**
 * In this situation a scene was created where points appeared behind the camera. Taken from real data
 */
@Test
void real_world_case0() {
    DMatrixRMaj P2 = new DMatrixRMaj(3, 4, true, 71.2714309, -1.50598476, -354.50553, -.052935998, -1.28683386, 39.1891727, 672.658283, -.994592935, .00056663, -.019338274, 70.0397946, -.000445996);
    DMatrixRMaj P3 = new DMatrixRMaj(3, 4, true, 32.4647875, -1.02054892, -241.805355, -.054715714, -1.8370892, -.061992654, .486096194, -1.00684043, .000185405, -.010046842, 31.8668685, -.000209807);
    DogArray<AssociatedTuple> observations = new DogArray<>(() -> new AssociatedTupleN(3));
    // These are in front of both cameras
    add(-47.208221435546875, -14.024078369140625, -49.9302978515625, 36.35797119140625, -50.079071044921875, 77.59286499023438, observations);
    add(-203.9057159423828, 70.39932250976562, -207.64544677734375, 124.38552856445312, -206.31866455078125, 172.38186645507812, observations);
    add(-362.7781524658203, -218.54442596435547, -361.6542053222656, -160.6702880859375, -363.30285263061523, -107.35969543457031, observations);
    add(-154.99310302734375, 3.35784912109375, -158.14512634277344, 55.362579345703125, -157.7862548828125, 100.77597045898438, observations);
    add(-170.89407348632812, -181.27266693115234, -172.10398864746094, -127.54672241210938, -174.48524475097656, -81.65957641601562, observations);
    add(41.3905029296875, 170.15188598632812, 39.365081787109375, 221.3468017578125, 43.634307861328125, 261.2353515625, observations);
    add(-350.1354789733887, -229.5992660522461, -349.162899017334, -171.76145935058594, -351.1237335205078, -118.83564758300781, observations);
    add(-50.12109375, -14.451873779296875, -52.87139892578125, 35.835052490234375, -53.014801025390625, 77.25506591796875, observations);
    add(-250.23069763183594, -212.5504379272461, -250.5589599609375, -156.41912841796875, -252.87100219726562, -107.27978515625, observations);
    // These are behind at least one camera
    add(154.89532470703125, -21.821807861328125, 151.21435546875, 41.2327880859375, 151.974365234375, 93.64697265625, observations);
    add(226.85003662109375, -95.77021789550781, 221.5345458984375, -35.9564208984375, 219.90155029296875, 12.154052734375, observations);
    add(237.870361328125, -46.12437438964844, 232.88519287109375, 13.570709228515625, 232.98577880859375, 61.028564453125, observations);
    add(162.7314453125, -165.1600341796875, 156.9556884765625, -99.56578063964844, 154.2447509765625, -45.94012451171875, observations);
    add(283.9959716796875, -147.1155242919922, 276.13848876953125, -86.35987854003906, 273.4132080078125, -40.23883056640625, observations);
    add(135.57574462890625, -232.8561019897461, 129.67437744140625, -163.39407348632812, 125.60736083984375, -107.20663452148438, observations);
    add(-21.8720703125, -162.5299530029297, -24.70025634765625, -101.63801574707031, -27.263427734375, -50.05320739746094, observations);
    add(62.40008544921875, -173.78022003173828, 59.92376708984375, -105.06491088867188, 56.91351318359375, -45.15827941894531, observations);
    add(-63.860626220703125, -259.0756492614746, -65.89141845703125, -195.2255096435547, -69.55535888671875, -142.1841278076172, observations);
    List<ElevateViewInfo> views = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        views.add(new ElevateViewInfo(800, 600, i));
    }
    List<DMatrixRMaj> inputCameras = new ArrayList<>();
    inputCameras.add(P2);
    inputCameras.add(P3);
    var results = new MetricCameras();
    ProjectiveToMetricCameras alg = createEstimator(false);
    assertTrue(alg.process(views, inputCameras, observations.toList(), results));
    // Yes internally most implementations run this function, but the number of invalid was > 0 before
    var checkMatches = new ResolveSignAmbiguityPositiveDepth();
    checkMatches.process(observations.toList(), results);
    assertFalse(checkMatches.signChanged);
    assertEquals(0, checkMatches.bestInvalid);
}
Also used : DMatrixRMaj(org.ejml.data.DMatrixRMaj) AssociatedTupleN(boofcv.struct.geo.AssociatedTupleN) ArrayList(java.util.ArrayList) DogArray(org.ddogleg.struct.DogArray) MetricCameras(boofcv.alg.geo.MetricCameras) AssociatedTuple(boofcv.struct.geo.AssociatedTuple) ResolveSignAmbiguityPositiveDepth(boofcv.alg.geo.selfcalib.ResolveSignAmbiguityPositiveDepth) ElevateViewInfo(boofcv.struct.calib.ElevateViewInfo) Test(org.junit.jupiter.api.Test)

Example 58 with DogArray

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

the class TestUtilFeature method setSource_2D.

@Test
void setSource_2D() {
    var associate = new PAssociateDescriptionSets2D<>(new MockAssociateDescriptionSets2D());
    var descriptors = new DogArray<>(() -> new TupleDesc_F64(1));
    var locs = new DogArray<>(Point2D_F64::new);
    var sets = new DogArray_I32();
    for (int i = 0; i < 5; i++) {
        descriptors.grow();
        locs.grow();
    }
    sets.add(1);
    sets.add(0);
    sets.add(0);
    sets.add(2);
    sets.add(0);
    associate.initializeSets(3);
    UtilFeature.setSource(descriptors, sets, locs, associate);
    assertEquals(3, associate.getCountSrc(0));
    assertEquals(1, associate.getCountSrc(1));
    assertEquals(1, associate.getCountSrc(2));
    for (int i = 0; i < 3; i++) {
        assertEquals(0, associate.getCountDst(i));
    }
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Point2D_F64(georegression.struct.point.Point2D_F64) DogArray_I32(org.ddogleg.struct.DogArray_I32) DogArray(org.ddogleg.struct.DogArray) Test(org.junit.jupiter.api.Test)

Example 59 with DogArray

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

the class TestUtilFeature method setDestination.

@Test
void setDestination() {
    var associate = new PAssociateDescriptionSets<>(new MockAssociateDescription());
    var descriptors = new DogArray<>(() -> new TupleDesc_F64(1));
    var sets = new DogArray_I32();
    for (int i = 0; i < 5; i++) {
        descriptors.grow();
    }
    sets.add(1);
    sets.add(0);
    sets.add(0);
    sets.add(2);
    sets.add(0);
    associate.initialize(3);
    UtilFeature.setDestination(descriptors, sets, associate);
    assertEquals(3, associate.getCountDst(0));
    assertEquals(1, associate.getCountDst(1));
    assertEquals(1, associate.getCountDst(2));
    for (int i = 0; i < 3; i++) {
        assertEquals(0, associate.getCountSrc(i));
    }
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) DogArray_I32(org.ddogleg.struct.DogArray_I32) DogArray(org.ddogleg.struct.DogArray) Test(org.junit.jupiter.api.Test)

Example 60 with DogArray

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

the class TestUtilFeature method setSource.

/**
 * Simple test to see if it broke the features up when adding them to the associator
 */
@Test
void setSource() {
    var associate = new PAssociateDescriptionSets<>(new MockAssociateDescription());
    var descriptors = new DogArray<>(() -> new TupleDesc_F64(1));
    var sets = new DogArray_I32();
    for (int i = 0; i < 5; i++) {
        descriptors.grow();
    }
    sets.add(1);
    sets.add(0);
    sets.add(0);
    sets.add(2);
    sets.add(0);
    associate.initialize(3);
    UtilFeature.setSource(descriptors, sets, associate);
    assertEquals(3, associate.getCountSrc(0));
    assertEquals(1, associate.getCountSrc(1));
    assertEquals(1, associate.getCountSrc(2));
    for (int i = 0; i < 3; i++) {
        assertEquals(0, associate.getCountDst(i));
    }
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) DogArray_I32(org.ddogleg.struct.DogArray_I32) DogArray(org.ddogleg.struct.DogArray) Test(org.junit.jupiter.api.Test)

Aggregations

DogArray (org.ddogleg.struct.DogArray)79 Test (org.junit.jupiter.api.Test)48 ArrayList (java.util.ArrayList)27 Point3D_F64 (georegression.struct.point.Point3D_F64)18 DogArray_I32 (org.ddogleg.struct.DogArray_I32)17 Point2D_F64 (georegression.struct.point.Point2D_F64)16 GrayU8 (boofcv.struct.image.GrayU8)13 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)10 Point2D_I32 (georegression.struct.point.Point2D_I32)7 DMatrixRMaj (org.ejml.data.DMatrixRMaj)7 BufferedImage (java.awt.image.BufferedImage)6 Point3dRgbI_F64 (boofcv.struct.Point3dRgbI_F64)5 CameraPinholeBrown (boofcv.struct.calib.CameraPinholeBrown)5 List (java.util.List)5 PositionPatternNode (boofcv.alg.fiducial.qrcode.PositionPatternNode)4 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)4 GrayF32 (boofcv.struct.image.GrayF32)4 PointCloudViewer (boofcv.visualize.PointCloudViewer)4 Se3_F64 (georegression.struct.se.Se3_F64)4 FactoryNearestNeighbor (org.ddogleg.nn.FactoryNearestNeighbor)4