use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.
the class BenchmarkAssociationSpeedSurf method createSet.
private FastQueue<TupleDesc_F64> createSet(String imageName) {
try {
BufferedImage image = ImageIO.read(new File(imageName));
GrayF32 gray = ConvertBufferedImage.convertFrom(image, (GrayF32) null);
FastQueue<TupleDesc_F64> ret = new FastQueue<>(10, TupleDesc_F64.class, false);
detector.detect(gray);
for (int i = 0; i < detector.getNumberOfFeatures(); i++) {
ret.add(detector.getDescription(i).copy());
}
return ret;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.
the class TestPnPLepetitEPnP method selectControlPoints.
@Test
public void selectControlPoints() {
List<Point3D_F64> worldPts = GeoTestingOps.randomPoints_F64(-1, 10, -5, 20, 0.1, 0.5, 30, rand);
FastQueue<Point3D_F64> controlPts = new FastQueue<>(4, Point3D_F64.class, true);
PnPLepetitEPnP alg = new PnPLepetitEPnP();
alg.selectWorldControlPoints(worldPts, controlPts);
// check that each row is unique
for (int i = 0; i < 4; i++) {
Point3D_F64 ci = controlPts.get(i);
for (int j = i + 1; j < 4; j++) {
Point3D_F64 cj = controlPts.get(j);
double dx = ci.x - cj.x;
double dy = ci.y - cj.y;
double dz = ci.z - cj.z;
double sum = Math.abs(dx) + Math.abs(dy) + Math.abs(dz);
assertTrue(sum > 0.00001);
}
}
}
use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.
the class TestPnPLepetitEPnP method selectWorldControlPoints_planar.
@Test
public void selectWorldControlPoints_planar() {
List<Point3D_F64> worldPts = CommonHomographyChecks.createRandomPlane(rand, 3, 30);
FastQueue<Point3D_F64> controlPts = new FastQueue<>(4, Point3D_F64.class, true);
PnPLepetitEPnP alg = new PnPLepetitEPnP();
alg.selectWorldControlPoints(worldPts, controlPts);
assertEquals(3, alg.numControl);
// check that each row is unique
for (int i = 0; i < 3; i++) {
Point3D_F64 ci = controlPts.get(i);
for (int j = i + 1; j < 3; j++) {
Point3D_F64 cj = controlPts.get(j);
double dx = ci.x - cj.x;
double dy = ci.y - cj.y;
double dz = ci.z - cj.z;
double sum = Math.abs(dx) + Math.abs(dy) + Math.abs(dz);
assertTrue(sum > 0.00001);
}
}
}
use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.
the class TestTldAdjustRegion method process.
@Test
public void process() {
ScaleTranslate2D motion = new ScaleTranslate2D(1.5, 2, 3);
FastQueue<AssociatedPair> pairs = new FastQueue<>(AssociatedPair.class, true);
for (int i = 0; i < 200; i++) {
AssociatedPair p = pairs.grow();
p.p1.x = rand.nextGaussian() * 2;
p.p1.y = rand.nextGaussian() * 2;
p.p2.x = p.p1.x * motion.scale + motion.transX;
p.p2.y = p.p1.y * motion.scale + motion.transY;
}
Rectangle2D_F64 rect = new Rectangle2D_F64(10, 20, 30, 40);
TldAdjustRegion alg = new TldAdjustRegion(30);
alg.init(300, 400);
assertTrue(alg.process(pairs, rect));
assertEquals(17, rect.p0.x, 1e-8);
assertEquals(33, rect.p0.y, 1e-8);
assertEquals(47, rect.p1.x, 1e-8);
assertEquals(63, rect.p1.y, 1e-8);
}
use of org.ddogleg.struct.FastQueue in project BoofCV by lessthanoptimal.
the class TestBinaryEllipseDetectorPixel method undistortContour_WithDistortion.
/**
* Undistort the image when distortion model is provided
*/
@Test
public void undistortContour_WithDistortion() {
List<Point2D_I32> input = new ArrayList<>();
FastQueue<Point2D_F64> output = new FastQueue<>(Point2D_F64.class, true);
for (int i = 0; i < 10; i++) {
input.add(new Point2D_I32(i, i));
}
BinaryEllipseDetectorPixel alg = new BinaryEllipseDetectorPixel();
alg.setLensDistortion(new PixelTransformAffine_F32(new Affine2D_F32(1, 0, 0, 1, 10.0f, 0)));
alg.undistortContour(input, output);
assertEquals(input.size(), output.size);
for (int i = 0; i < input.size(); i++) {
Point2D_I32 p = input.get(i);
assertEquals(p.x + 10, output.get(i).x, 1e-8);
assertEquals(p.y, output.get(i).y, 1e-8);
}
}
Aggregations