use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method extractCameraMatrices.
@Test
public void extractCameraMatrices() {
DMatrixRMaj P2 = new DMatrixRMaj(3, 4);
DMatrixRMaj P3 = new DMatrixRMaj(3, 4);
TrifocalTensor input = tensor.copy();
MultiViewOps.extractCameraMatrices(input, P2, P3);
// make sure the input was not modified
for (int i = 0; i < 3; i++) assertTrue(MatrixFeatures_DDRM.isIdentical(tensor.getT(i), input.getT(i), 1e-8));
// Using found camera matrices render the point's location
Point3D_F64 X = new Point3D_F64(0.1, 0.05, 2);
Point2D_F64 x1 = new Point2D_F64(X.x / X.z, X.y / X.z);
Point2D_F64 x2 = PerspectiveOps.renderPixel(P2, X);
Point2D_F64 x3 = PerspectiveOps.renderPixel(P3, X);
// validate correctness by testing a constraint on the points
DMatrixRMaj A = new DMatrixRMaj(3, 3);
MultiViewOps.constraint(tensor, x1, x2, x3, A);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
assertEquals(0, A.get(i, j), 1e-7);
}
}
}
use of georegression.struct.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestNormalizationPoint2D method apply_one.
@Test
public void apply_one() {
NormalizationPoint2D n = new NormalizationPoint2D(1, 2, 3, 4);
Point2D_F64 a = new Point2D_F64(1, 2);
n.apply(a);
n.remove(a);
assertEquals(1, a.x, GrlConstants.TEST_F64);
assertEquals(2, a.y, GrlConstants.TEST_F64);
}
use of georegression.struct.point.Point2D_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.point.Point2D_F64 in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method renderPixel_intrinsic.
@Test
public void renderPixel_intrinsic() {
Point3D_F64 X = new Point3D_F64(0.1, -0.05, 3);
CameraPinholeRadial intrinsic = new CameraPinholeRadial(100, 150, 0.1, 120, 209, 500, 600);
double normX = X.x / X.z;
double normY = X.y / X.z;
Point2D_F64 expected = new Point2D_F64();
PerspectiveOps.convertNormToPixel(intrinsic, normX, normY, expected);
Point2D_F64 found = PerspectiveOps.renderPixel(intrinsic, X);
assertEquals(expected.x, found.x, 1e-8);
assertEquals(expected.y, found.y, 1e-8);
}
use of georegression.struct.point.Point2D_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);
}
Aggregations