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));
}
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;
}
}
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));
}
}
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));
}
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();
}
}
Aggregations