Search in sources :

Example 16 with DogArray

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

the class TestMicroQrCodeDecoderImage method simple_rotateSquare.

/**
 * Rotate the square and see if it can always decode it
 */
@Test
void simple_rotateSquare() {
    MicroQrCode qr = new MicroQrCodeEncoder().addAutomatic("123LK").fixate();
    GrayU8 image = render(qr);
    var patterns = new DogArray<>(PositionPatternNode::new);
    PositionPatternNode pp = addPositionPattern(qr, patterns);
    var alg = new MicroQrCodeDecoderImage<>(null, "", GrayU8.class);
    for (int i = 0; i < 4; i++) {
        alg.process(patterns.toList(), image);
        assertEquals(1, alg.found.size());
        assertEquals(0, alg.failures.size());
        assertEquals("123LK", alg.found.get(0).message);
        // Rotate the polygon so that it now needs to compensate for that
        UtilPolygons2D_F64.shiftDown(pp.square);
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) PositionPatternNode(boofcv.alg.fiducial.qrcode.PositionPatternNode) DogArray(org.ddogleg.struct.DogArray) Test(org.junit.jupiter.api.Test)

Example 17 with DogArray

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

the class TestMicroQrCodeDecoderImage method decode_byte.

/**
 * Decode a marker with byte encoded data
 */
@Test
void decode_byte() {
    MicroQrCode qr = new MicroQrCodeEncoder().addBytes("123LK%$63").fixate();
    GrayU8 image = render(qr);
    var patterns = new DogArray<>(PositionPatternNode::new);
    addPositionPattern(qr, patterns);
    var alg = new MicroQrCodeDecoderImage<>(null, "", GrayU8.class);
    alg.process(patterns.toList(), image);
    assertEquals(1, alg.found.size());
    assertEquals(0, alg.failures.size());
    assertEquals("123LK%$63", alg.found.get(0).message);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) PositionPatternNode(boofcv.alg.fiducial.qrcode.PositionPatternNode) DogArray(org.ddogleg.struct.DogArray) Test(org.junit.jupiter.api.Test)

Example 18 with DogArray

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

the class GenericAssociateGreedyChecks method createData.

protected DogArray<TupleDesc_F64> createData(double... values) {
    DogArray<TupleDesc_F64> ret = new DogArray<>(() -> new TupleDesc_F64(1));
    ret.resize(values.length);
    for (int i = 0; i < values.length; i++) {
        ret.get(i).setTo(values[i]);
    }
    return ret;
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) DogArray(org.ddogleg.struct.DogArray)

Example 19 with DogArray

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

the class TestAssociateGreedyDesc_MT method createData.

public static DogArray<TupleDesc_F64> createData(int count) {
    Random rand = new Random(234);
    DogArray<TupleDesc_F64> ret = new DogArray<>(count, () -> new TupleDesc_F64(1));
    for (int i = 0; i < count; i++) {
        ret.grow().setTo(rand.nextDouble() * 10);
    }
    return ret;
}
Also used : Random(java.util.Random) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) DogArray(org.ddogleg.struct.DogArray)

Example 20 with DogArray

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

the class TestUtilFeature method setDestination_2D.

@Test
void setDestination_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.setDestination(descriptors, sets, locs, 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) 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)

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