Search in sources :

Example 56 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class ChecksPointDeformKeyPoints method createTestPoints.

private List<Point2D_F32> createTestPoints() {
    List<Point2D_F32> src = new ArrayList<>();
    src.add(new Point2D_F32(10, 20));
    src.add(new Point2D_F32(15, 10));
    src.add(new Point2D_F32(20, 30));
    src.add(new Point2D_F32(25, 60));
    return src;
}
Also used : ArrayList(java.util.ArrayList) Point2D_F32(georegression.struct.point.Point2D_F32)

Example 57 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class ChecksPointDeformKeyPoints method checkPointsCopied.

/**
 * Sees if a local copy of inputs points is not made
 */
@Test
public void checkPointsCopied() {
    List<Point2D_F32> src = createTestPoints();
    List<Point2D_F32> dst = createTestPoints();
    PointDeformKeyPoints alg = createAlgorithm();
    alg.setImageShape(80, 100);
    alg.setSource(src);
    alg.setSource(dst);
    Point2D_F32 expected = new Point2D_F32();
    alg.compute(12, 19.5f, expected);
    for (int i = 0; i < src.size(); i++) {
        src.get(i).x += 2.5;
        dst.get(i).x += 2.5;
    }
    // see if the results change after modifying the input points
    Point2D_F32 found = new Point2D_F32();
    alg.compute(12, 19.5f, found);
    assertEquals(expected.x, found.x, GrlConstants.TEST_F32);
    assertEquals(expected.y, found.y, GrlConstants.TEST_F32);
}
Also used : Point2D_F32(georegression.struct.point.Point2D_F32) Test(org.junit.Test)

Example 58 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class TestTldFernClassifier method computeFernValue.

@Test
public void computeFernValue() {
    TldFernDescription fern = new TldFernDescription(rand, 10);
    ImageRectangle r = new ImageRectangle(2, 20, 12, 28);
    float cx = r.x0 + (r.getWidth() - 1) / 2.0f;
    float cy = r.x0 + (r.getHeight() - 1) / 2.0f;
    float w = r.getWidth() - 1;
    float h = r.getHeight() - 1;
    boolean[] expected = new boolean[10];
    for (int i = 0; i < 10; i++) {
        Point2D_F32 a = fern.pairs[i].a;
        Point2D_F32 b = fern.pairs[i].b;
        float valA = interpolate.get(cx + a.x * w, cy + a.y * h);
        float valB = interpolate.get(cx + b.x * w, cy + b.y * h);
        expected[9 - i] = valA < valB;
    }
    TldFernClassifier<GrayU8> alg = createAlg();
    alg.setImage(input);
    int found = alg.computeFernValue(cx, cy, r.getWidth(), r.getHeight(), fern);
    for (int i = 0; i < 10; i++) {
        assertTrue(expected[i] == (((found >> i) & 0x0001) == 1));
    }
}
Also used : ImageRectangle(boofcv.struct.ImageRectangle) Point2D_F32(georegression.struct.point.Point2D_F32) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 59 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class TestTldFernClassifier method computeFernValueRand.

@Test
public void computeFernValueRand() {
    TldFernDescription fern = new TldFernDescription(rand, 10);
    ImageRectangle r = new ImageRectangle(2, 20, 12, 28);
    float cx = r.x0 + r.getWidth() / 2.0f;
    float cy = r.x0 + r.getHeight() / 2.0f;
    float w = r.getWidth();
    float h = r.getHeight();
    boolean[] expected = new boolean[10];
    for (int i = 0; i < 10; i++) {
        Point2D_F32 a = fern.pairs[i].a;
        Point2D_F32 b = fern.pairs[i].b;
        float valA = interpolate.get(cx + a.x * w, cy + a.y * h);
        float valB = interpolate.get(cx + b.x * w, cy + b.y * h);
        expected[9 - i] = valA < valB;
    }
    TldFernClassifier<GrayU8> alg = createAlg();
    alg.setImage(input);
    int found = alg.computeFernValueRand(cx, cy, w, h, fern);
    int numDiff = 0;
    for (int i = 0; i < 10; i++) {
        if (expected[i] != (((found >> i) & 0x0001) == 1)) {
            numDiff++;
        }
    }
    assertTrue(numDiff != 0);
    assertTrue(numDiff < 10);
}
Also used : ImageRectangle(boofcv.struct.ImageRectangle) Point2D_F32(georegression.struct.point.Point2D_F32) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 60 with Point2D_F32

use of georegression.struct.point.Point2D_F32 in project BoofCV by lessthanoptimal.

the class TestQrCodeBinaryGridReader method simpleChecks.

/**
 * Create a perfect undistorted image and read from it
 */
@Test
public void simpleChecks() {
    QrCodeGeneratorImage generator = new QrCodeGeneratorImage(4);
    QrCode qr = new QrCodeEncoder().addAlphanumeric("HI1234").fixate();
    generator.render(qr);
    QrCodeBinaryGridReader<GrayU8> reader = new QrCodeBinaryGridReader<>(GrayU8.class);
    reader.setImage(generator.gray);
    reader.setMarker(qr);
    // check coordinate transforms
    Point2D_F32 pixel = new Point2D_F32();
    Point2D_F32 grid = new Point2D_F32();
    reader.imageToGrid(4 * 6 + 1, 4 * 10 + 1, grid);
    assertEquals(10.25, grid.y, 0.1);
    assertEquals(6.25, grid.x, 0.1);
    reader.gridToImage(10, 6, pixel);
    assertEquals(10 * 4, pixel.y, 0.1);
    assertEquals(6 * 4, pixel.x, 0.1);
    // check reading of bits
    QrCodeMaskPattern mask = qr.mask;
    List<Point2D_I32> locations = QrCode.LOCATION_BITS[qr.version];
    PackedBits8 bits = PackedBits8.wrap(qr.rawbits, qr.rawbits.length * 8);
    for (int i = 0; i < bits.size; i++) {
        Point2D_I32 p = locations.get(i);
        int value = mask.apply(p.y, p.x, reader.readBit(p.y, p.x));
        assertEquals(value, bits.get(i));
    }
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) GrayU8(boofcv.struct.image.GrayU8) Point2D_F32(georegression.struct.point.Point2D_F32) Test(org.junit.Test)

Aggregations

Point2D_F32 (georegression.struct.point.Point2D_F32)98 Test (org.junit.Test)36 Point3D_F32 (georegression.struct.point.Point3D_F32)10 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)9 LineSegment2D_F32 (georegression.struct.line.LineSegment2D_F32)8 ArrayList (java.util.ArrayList)8 Point2D_F64 (georegression.struct.point.Point2D_F64)7 FMatrixRMaj (org.ejml.data.FMatrixRMaj)7 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)5 LineParametric2D_F32 (georegression.struct.line.LineParametric2D_F32)5 Point2Transform3_F32 (boofcv.struct.distort.Point2Transform3_F32)4 Point3Transform2_F32 (boofcv.struct.distort.Point3Transform2_F32)4 GrayF32 (boofcv.struct.image.GrayF32)4 ClosestPoint2D_F32 (georegression.metric.ClosestPoint2D_F32)4 PointToPixelTransform_F32 (boofcv.alg.distort.PointToPixelTransform_F32)3 CameraPinhole (boofcv.struct.calib.CameraPinhole)3 GrayU8 (boofcv.struct.image.GrayU8)3 PixelTransformCached_F32 (boofcv.alg.distort.PixelTransformCached_F32)2 PinholePtoN_F32 (boofcv.alg.distort.pinhole.PinholePtoN_F32)2 CalibrationObservation (boofcv.alg.geo.calibration.CalibrationObservation)2