use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method inducedHomography13.
@Test
public void inducedHomography13() {
Point3D_F64 X = new Point3D_F64(0.1, -0.05, 2);
computeLines(X, line1, line2, line3);
// When the tensor was constructed the first view was assumed to be [I|0], which
// is why normalized image coordinates are used for the first view
Point2D_F64 p1 = PerspectiveOps.renderPixel(new Se3_F64(), null, X);
Point2D_F64 p3 = PerspectiveOps.renderPixel(worldToCam3, K, X);
DMatrixRMaj H13 = MultiViewOps.inducedHomography13(tensor, line2, null);
Point2D_F64 found = new Point2D_F64();
GeometryMath_F64.mult(H13, p1, found);
assertEquals(p3.x, found.x, 1e-8);
assertEquals(p3.y, found.y, 1e-8);
}
use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method renderPixel_cameramatrix.
@Test
public void renderPixel_cameramatrix() {
Point3D_F64 X = new Point3D_F64(0.1, -0.05, 3);
Se3_F64 worldToCamera = new Se3_F64();
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, -0.05, 0.03, worldToCamera.getR());
worldToCamera.getT().set(0.2, 0.01, -0.03);
DMatrixRMaj K = RandomMatrices_DDRM.triangularUpper(3, 0, -1, 1, rand);
Point3D_F64 X_cam = SePointOps_F64.transform(worldToCamera, X, null);
Point2D_F64 found;
DMatrixRMaj P = PerspectiveOps.createCameraMatrix(worldToCamera.R, worldToCamera.T, K, null);
Point2D_F64 expected = new Point2D_F64();
expected.x = X_cam.x / X_cam.z;
expected.y = X_cam.y / X_cam.z;
GeometryMath_F64.mult(K, expected, expected);
found = PerspectiveOps.renderPixel(P, X);
assertEquals(expected.x, found.x, 1e-8);
assertEquals(expected.y, found.y, 1e-8);
}
use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method scaleIntrinsic.
@Test
public void scaleIntrinsic() {
Point3D_F64 X = new Point3D_F64(0.1, 0.3, 2);
CameraPinholeRadial param = new CameraPinholeRadial(200, 300, 2, 250, 260, 200, 300);
DMatrixRMaj K = PerspectiveOps.calibrationMatrix(param, (DMatrixRMaj) null);
// find the pixel location in the unscaled image
Point2D_F64 a = PerspectiveOps.renderPixel(new Se3_F64(), K, X);
PerspectiveOps.scaleIntrinsic(param, 0.5);
K = PerspectiveOps.calibrationMatrix(param, (DMatrixRMaj) null);
// find the pixel location in the scaled image
Point2D_F64 b = PerspectiveOps.renderPixel(new Se3_F64(), K, X);
assertEquals(a.x * 0.5, b.x, 1e-8);
assertEquals(a.y * 0.5, b.y, 1e-8);
}
use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method renderPixel_SE.
@Test
public void renderPixel_SE() {
Point3D_F64 X = new Point3D_F64(0.1, -0.05, 3);
Se3_F64 worldToCamera = new Se3_F64();
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, -0.05, 0.03, worldToCamera.getR());
worldToCamera.getT().set(0.2, 0.01, -0.03);
DMatrixRMaj K = RandomMatrices_DDRM.triangularUpper(3, 0, -1, 1, rand);
Point3D_F64 X_cam = SePointOps_F64.transform(worldToCamera, X, null);
Point2D_F64 found;
// calibrated case
found = PerspectiveOps.renderPixel(worldToCamera, null, X);
assertEquals(X_cam.x / X_cam.z, found.x, 1e-8);
assertEquals(X_cam.y / X_cam.z, found.y, 1e-8);
// uncalibrated case
Point2D_F64 expected = new Point2D_F64();
expected.x = X_cam.x / X_cam.z;
expected.y = X_cam.y / X_cam.z;
GeometryMath_F64.mult(K, expected, expected);
found = PerspectiveOps.renderPixel(worldToCamera, K, X);
assertEquals(expected.x, found.x, 1e-8);
assertEquals(expected.y, found.y, 1e-8);
}
use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.
the class TestPositiveDepthConstraintCheck method testPositive.
/**
* Point a point in front of both cameras and see if it returns true
*/
@Test
public void testPositive() {
// 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, 2);
// 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();
assertTrue(alg.checkConstraint(obsA, obsB, fromAtoB));
}
Aggregations