use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class DisparityPointCloudViewer method createWorldToCamera.
public Se3_F64 createWorldToCamera() {
// pick an appropriate amount of motion for the scene
double z = baseline * focalLengthX / (minDisparity + rangeDisparity);
double adjust = baseline / 20.0;
Vector3D_F64 rotPt = new Vector3D_F64(offsetX * adjust, offsetY * adjust, z * range);
double radians = tiltAngle * Math.PI / 180.0;
DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, radians, 0, 0, null);
Se3_F64 a = new Se3_F64(R, rotPt);
return a;
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestDecomposeEssential method multipleCalls.
/**
* Checks to see if the same solution is returned when invoked multiple times
*/
@Test
public void multipleCalls() {
DMatrixRMaj R = ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0.1, -0.4, 0.5, null);
Vector3D_F64 T = new Vector3D_F64(2, 1, -3);
DMatrixRMaj E = MultiViewOps.createEssential(R, T);
DecomposeEssential alg = new DecomposeEssential();
// call it twice and see if it breaks
alg.decompose(E);
alg.decompose(E);
List<Se3_F64> solutions = alg.getSolutions();
assertEquals(4, solutions.size());
checkUnique(solutions);
checkHasOriginal(solutions, R, T);
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method homographyStereo2Lines.
@Test
public void homographyStereo2Lines() {
CommonHomographyInducedPlane common = new CommonHomographyInducedPlane();
PairLineNorm l1 = CommonHomographyInducedPlane.convert(common.p1, common.p2);
PairLineNorm l2 = CommonHomographyInducedPlane.convert(common.p1, common.p3);
DMatrixRMaj H = MultiViewOps.homographyStereo2Lines(common.F, l1, l2);
common.checkHomography(H);
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method decomposeCameraMatrix.
@Test
public void decomposeCameraMatrix() {
// compute an arbitrary projection matrix from known values
DMatrixRMaj K = PerspectiveOps.calibrationMatrix(200, 250, 0.0, 100, 110);
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 P = new DMatrixRMaj(3, 4);
DMatrixRMaj KP = new DMatrixRMaj(3, 4);
CommonOps_DDRM.insert(R, P, 0, 0);
P.set(0, 3, T.x);
P.set(1, 3, T.y);
P.set(2, 3, T.z);
CommonOps_DDRM.mult(K, P, KP);
// decompose the projection matrix
DMatrixRMaj foundK = new DMatrixRMaj(3, 3);
Se3_F64 foundPose = new Se3_F64();
MultiViewOps.decomposeCameraMatrix(KP, foundK, foundPose);
// recompute the projection matrix found the found results
DMatrixRMaj foundKP = new DMatrixRMaj(3, 4);
CommonOps_DDRM.insert(foundPose.getR(), P, 0, 0);
P.set(0, 3, foundPose.T.x);
P.set(1, 3, foundPose.T.y);
P.set(2, 3, foundPose.T.z);
CommonOps_DDRM.mult(foundK, P, foundKP);
// see if the two projection matrices are the same
assertTrue(MatrixFeatures_DDRM.isEquals(foundKP, KP, 1e-8));
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestMultiViewOps method canonicalCamera.
@Test
public void canonicalCamera() {
DMatrixRMaj K = PerspectiveOps.calibrationMatrix(200, 250, 0.0, 100, 110);
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);
DMatrixRMaj F = MultiViewOps.createFundamental(E, K);
Point3D_F64 e1 = new Point3D_F64();
Point3D_F64 e2 = new Point3D_F64();
CommonOps_DDRM.scale(-2.0 / F.get(0, 1), F);
MultiViewOps.extractEpipoles(F, e1, e2);
DMatrixRMaj P = MultiViewOps.canonicalCamera(F, e2, new Vector3D_F64(1, 1, 1), 2);
// recompose the fundamental matrix using the special equation for canonical cameras
DMatrixRMaj foundF = new DMatrixRMaj(3, 3);
DMatrixRMaj crossEpi = new DMatrixRMaj(3, 3);
GeometryMath_F64.crossMatrix(e2, crossEpi);
DMatrixRMaj M = new DMatrixRMaj(3, 3);
CommonOps_DDRM.extract(P, 0, 3, 0, 3, M, 0, 0);
CommonOps_DDRM.mult(crossEpi, M, foundF);
// see if they are equal up to a scale factor
CommonOps_DDRM.scale(1.0 / foundF.get(0, 1), foundF);
CommonOps_DDRM.scale(1.0 / F.get(0, 1), F);
assertTrue(MatrixFeatures_DDRM.isIdentical(F, foundF, 1e-8));
}
Aggregations