Search in sources :

Example 86 with Point2D_I32

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

the class ChecksGenericPointsToPolyline method checkIsConvex.

/**
 * Checks to see if this feature can be changed and is enforced
 */
@Test
public 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));
    GrowQueue_I32 found = new GrowQueue_I32();
    assertFalse(alg.process(contour, found));
    alg.setConvex(false);
    assertTrue(alg.process(contour, found));
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 87 with Point2D_I32

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

the class PackedSetsPoint2D_I32 method writeOverSet.

/**
 * Overwrites the points in the set with the list of points.
 *
 * @param points Points which are to be written into the set. Must be the same size as the set.
 */
public void writeOverSet(int which, List<Point2D_I32> points) {
    BlockIndexLength set = sets.get(which);
    if (set.length != points.size())
        throw new IllegalArgumentException("points and set don't have the same length");
    for (int i = 0; i < set.length; i++) {
        int index = set.start + i * 2;
        int blockIndex = set.block + index / blockLength;
        index %= blockLength;
        Point2D_I32 p = points.get(i);
        int[] block = blocks.get(blockIndex);
        block[index] = p.x;
        block[index + 1] = p.y;
    }
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32)

Example 88 with Point2D_I32

use of georegression.struct.point.Point2D_I32 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)

Example 89 with Point2D_I32

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

the class TestQrCodeCodeWordLocations method codeWordsFillAll.

public void codeWordsFillAll(int version) {
    QrCodeCodeWordLocations mask = setup(version);
    for (Point2D_I32 c : mask.bits) {
        mask.set(c.y, c.x, true);
    }
    // print(mask);
    // printCodeWordsBits(mask);
    // printCodeWords(mask);
    assertEquals(0, countFalse(mask));
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32)

Example 90 with Point2D_I32

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

the class TestQrCodeCodeWordLocations method printCodeWordsBits.

void printCodeWordsBits(QrCodeCodeWordLocations alg) {
    int N = alg.numRows;
    int[][] m = new int[N][N];
    for (int i = 0; i < alg.bits.size(); i++) {
        Point2D_I32 c = alg.bits.get(i);
        m[c.y][c.x] = (i % 8) + 1;
    }
    System.out.println("Shape " + N + " " + N);
    for (int row = 0; row < N; row++) {
        for (int col = 0; col < N; col++) {
            if (m[row][col] == 0)
                if (alg.get(row, col))
                    System.out.print("-");
                else
                    System.out.print("_");
            else
                System.out.print("" + m[row][col]);
        }
        System.out.println();
    }
}
Also used : Point2D_I32(georegression.struct.point.Point2D_I32)

Aggregations

Point2D_I32 (georegression.struct.point.Point2D_I32)153 Test (org.junit.Test)64 ArrayList (java.util.ArrayList)41 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)21 Point2D_F64 (georegression.struct.point.Point2D_F64)11 EdgeContour (boofcv.alg.feature.detect.edge.EdgeContour)8 GrayF32 (boofcv.struct.image.GrayF32)8 GrayS32 (boofcv.struct.image.GrayS32)7 Contour (boofcv.alg.filter.binary.Contour)6 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)6 GrayU8 (boofcv.struct.image.GrayU8)6 PackedSetsPoint2D_I32 (boofcv.struct.PackedSetsPoint2D_I32)5 RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)5 UtilPoint2D_I32 (georegression.geometry.UtilPoint2D_I32)4 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)4 EdgeSegment (boofcv.alg.feature.detect.edge.EdgeSegment)3 Corner (boofcv.alg.shapes.polyline.splitmerge.PolylineSplitMerge.Corner)3 FactoryDescribeImageDense (boofcv.factory.feature.dense.FactoryDescribeImageDense)3 PointIndex_I32 (boofcv.struct.PointIndex_I32)3 LineGeneral2D_F64 (georegression.struct.line.LineGeneral2D_F64)3