use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method createHomography_uncalibrated.
@Test
public void createHomography_uncalibrated() {
DMatrixRMaj K = new DMatrixRMaj(3, 3, true, 0.1, 0.001, 200, 0, 0.2, 250, 0, 0, 1);
DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, -0.01, 0.2, null);
Vector3D_F64 T = new Vector3D_F64(1, 1, 0.1);
T.normalize();
double d = 2;
Vector3D_F64 N = new Vector3D_F64(0, 0, 1);
DMatrixRMaj H = MultiViewOps.createHomography(R, T, d, N, K);
// Test using the following theorem: x2 = H*x1
// a point on the plane
Point3D_F64 P = new Point3D_F64(0.1, 0.2, d);
Point2D_F64 x0 = new Point2D_F64(P.x / P.z, P.y / P.z);
GeometryMath_F64.mult(K, x0, x0);
SePointOps_F64.transform(new Se3_F64(R, T), P, P);
Point2D_F64 x1 = new Point2D_F64(P.x / P.z, P.y / P.z);
GeometryMath_F64.mult(K, x1, x1);
Point2D_F64 found = new Point2D_F64();
GeometryMath_F64.mult(H, x0, found);
assertEquals(x1.x, found.x, 1e-8);
assertEquals(x1.y, found.y, 1e-8);
}
use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method constraint_homography.
@Test
public void constraint_homography() {
double d = 2;
Vector3D_F64 N = new Vector3D_F64(0, 0, 1);
Point3D_F64 X = new Point3D_F64(0.1, -0.4, d);
DMatrixRMaj H = MultiViewOps.createHomography(worldToCam2.getR(), worldToCam2.getT(), d, N);
Point2D_F64 p1 = PerspectiveOps.renderPixel(new Se3_F64(), null, X);
Point2D_F64 p2 = PerspectiveOps.renderPixel(worldToCam2, null, X);
Point2D_F64 found = MultiViewOps.constraintHomography(H, p1, null);
assertEquals(p2.x, found.x, 1e-8);
assertEquals(p2.y, found.y, 1e-8);
}
use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.
the class TestPositiveDepthConstraintCheck method testNegative.
/**
* Point a point in behind the cameras
*/
@Test
public void testNegative() {
// create transform from A to B
DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, -0.05, 0, null);
Vector3D_F64 T = new Vector3D_F64(1, 0, 0);
Se3_F64 fromAtoB = new Se3_F64(R, T);
// point in front of both cameras
Point3D_F64 pt = new Point3D_F64(0, 0, -1);
// create observations of the point in calibrated coordinates
Point2D_F64 obsA = new Point2D_F64(0, 0);
Point3D_F64 pt_inB = SePointOps_F64.transform(fromAtoB, pt, null);
Point2D_F64 obsB = new Point2D_F64(pt_inB.x / pt_inB.z, pt_inB.y / pt_inB.z);
PositiveDepthConstraintCheck alg = new PositiveDepthConstraintCheck();
assertFalse(alg.checkConstraint(obsA, obsB, fromAtoB));
}
use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.
the class TestParamFundamentalEpipolar method backAndForth.
@Test
public void backAndForth() {
DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 1, 2, -0.5, null);
Vector3D_F64 T = new Vector3D_F64(0.5, 0.7, -0.3);
DMatrixRMaj E = MultiViewOps.createEssential(R, T);
double[] param = new double[7];
ParamFundamentalEpipolar alg = new ParamFundamentalEpipolar();
DMatrixRMaj found = new DMatrixRMaj(3, 3);
alg.encode(E, param);
alg.decode(param, found);
// normalize to take in account scale different when testing
CommonOps_DDRM.divide(E.get(2, 2), E);
CommonOps_DDRM.divide(found.get(2, 2), found);
assertTrue(MatrixFeatures_DDRM.isEquals(E, found, 1e-8));
}
use of georegression.struct.point.Vector3D_F64 in project BoofCV by lessthanoptimal.
the class TestNarrowToWidePtoP_F64 method checkFOVBounds.
/**
* Request points at the border and see if it has the expected vertical and horizontal FOV
*/
@Test
public void checkFOVBounds() {
NarrowToWidePtoP_F64 alg = createAlg();
Point2D_F64 foundA = new Point2D_F64();
Point2D_F64 foundB = new Point2D_F64();
Point3D_F64 vA = new Point3D_F64();
Point3D_F64 vB = new Point3D_F64();
// Compute the horizontal FOV
alg.compute(0, 250, foundA);
alg.compute(500, 250, foundB);
Point2Transform3_F64 wideToSphere = createModelWide().undistortPtoS_F64();
wideToSphere.compute(foundA.x, foundA.y, vA);
wideToSphere.compute(foundB.x, foundB.y, vB);
double found = UtilVector3D_F64.acute(new Vector3D_F64(vA), new Vector3D_F64(vB));
double expected = 2.0 * Math.atan(250.0 / 400.0);
assertEquals(expected, found, 0.01);
// Compute the vertical FOV
alg.compute(250, 0, foundA);
alg.compute(250, 500, foundB);
wideToSphere.compute(foundA.x, foundA.y, vA);
wideToSphere.compute(foundB.x, foundB.y, vB);
found = UtilVector3D_F64.acute(new Vector3D_F64(vA), new Vector3D_F64(vB));
expected = 2.0 * Math.atan(250.0 / 400.0);
assertEquals(expected, found, 0.001);
}
Aggregations