use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class CommonHomographyChecks method createScene.
public void createScene(int numPoints, boolean isPixels) {
// define the camera's motion
motion = new Se3_F64();
motion.getR().set(ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.05, -0.03, 0.02, null));
motion.getT().set(0.1, -0.1, 0.01);
// randomly generate points in space
pts = createRandomPlane(rand, d, numPoints);
// transform points into second camera's reference frame
pairs = new ArrayList<>();
for (Point3D_F64 p1 : pts) {
Point3D_F64 p2 = SePointOps_F64.transform(motion, p1, null);
AssociatedPair pair = new AssociatedPair();
pair.p1.set(p1.x / p1.z, p1.y / p1.z);
pair.p2.set(p2.x / p2.z, p2.y / p2.z);
pairs.add(pair);
if (isPixels) {
GeometryMath_F64.mult(K, pair.p1, pair.p1);
GeometryMath_F64.mult(K, pair.p2, pair.p2);
}
}
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class TestHomographyDirectLinearTransform method checkHomography.
/**
* Create a set of points perfectly on a plane and provide perfect observations of them
*
* @param N Number of observed points.
* @param isPixels Pixel or calibrated coordinates
* @param alg Algorithm being evaluated
*/
private void checkHomography(int N, boolean isPixels, HomographyDirectLinearTransform alg) {
createScene(N, isPixels);
// compute essential
assertTrue(alg.process(pairs, solution));
// validate by testing essential properties
// sanity check, F is not zero
assertTrue(NormOps_DDRM.normF(solution) > 0.001);
// see if it follows the epipolar constraint
for (AssociatedPair p : pairs) {
Point2D_F64 a = GeometryMath_F64.mult(solution, p.p1, new Point2D_F64());
double diff = a.distance(p.p2);
assertEquals(0, diff, 1e-8);
}
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class TestHomographyTotalLeastSquares method checkAgainstKnownH.
@Test
public void checkAgainstKnownH() {
DMatrixRMaj H = new DMatrixRMaj(new double[][] { { 1.5, 0, 0.5 }, { 0.2, 2, 0.2 }, { 0.05, 0, 1.5 } });
// DMatrixRMaj H = new DMatrixRMaj(new double[][]{{1,0,0},{0,1,0},{0,0,1}});
// DMatrixRMaj H = new DMatrixRMaj(new double[][]{{1,0,0},{0,1,0},{0,0,2.0}});
int N = 10000;
List<AssociatedPair> list = new ArrayList<>();
for (int i = 0; i < N; i++) {
AssociatedPair p = new AssociatedPair();
p.p1.x = rand.nextGaussian();
p.p1.y = rand.nextGaussian();
GeometryMath_F64.mult(H, p.p1, p.p2);
list.add(p);
}
CommonOps_DDRM.scale(1.0 / H.get(2, 2), H);
// H.print();
DMatrixRMaj found = new DMatrixRMaj(3, 3);
HomographyTotalLeastSquares alg = new HomographyTotalLeastSquares();
alg.process(list, found);
// System.out.println("\n\nFound");
// found.print();
assertTrue(MatrixFeatures_DDRM.isIdentical(found, H, UtilEjml.TEST_F64));
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class TestDistanceAffine2D method createRandomData.
@Override
public AssociatedPair createRandomData() {
Point2D_F64 p1 = new Point2D_F64(rand.nextGaussian(), rand.nextGaussian());
Point2D_F64 p2 = new Point2D_F64(rand.nextGaussian(), rand.nextGaussian());
return new AssociatedPair(p1, p2, false);
}
use of boofcv.struct.geo.AssociatedPair in project BoofCV by lessthanoptimal.
the class TestDistanceHomographyPixelSq method createRandomData.
@Override
public AssociatedPair createRandomData() {
Point2D_F64 p1 = new Point2D_F64(rand.nextGaussian(), rand.nextGaussian());
Point2D_F64 p2 = new Point2D_F64(rand.nextGaussian(), rand.nextGaussian());
return new AssociatedPair(p1, p2, false);
}
Aggregations