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