use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method calibrationMatrix.
@Test
public void calibrationMatrix() {
DMatrixRMaj K = PerspectiveOps.calibrationMatrix(1.0, 2, 3, 4, 5);
assertEquals(1, K.get(0, 0), 1e-3);
assertEquals(2, K.get(1, 1), 1e-3);
assertEquals(3, K.get(0, 1), 1e-3);
assertEquals(4, K.get(0, 2), 1e-3);
assertEquals(5, K.get(1, 2), 1e-3);
assertEquals(1, K.get(2, 2), 1e-3);
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestPerspectiveOps method matrixToParam.
@Test
public void matrixToParam() {
double fx = 1;
double fy = 2;
double skew = 3;
double cx = 4;
double cy = 5;
DMatrixRMaj K = new DMatrixRMaj(3, 3, true, fx, skew, cx, 0, fy, cy, 0, 0, 1);
CameraPinhole ret = PerspectiveOps.matrixToParam(K, 100, 200, null);
assertTrue(ret.fx == fx);
assertTrue(ret.fy == fy);
assertTrue(ret.skew == skew);
assertTrue(ret.cx == cx);
assertTrue(ret.cy == cy);
assertTrue(ret.width == 100);
assertTrue(ret.height == 200);
}
use of org.ejml.data.DMatrixRMaj 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));
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestRemoveRadialPtoN_F64 method checkAgainstAdd.
public void checkAgainstAdd(double t1, double t2) {
double fx = 600;
double fy = 500;
double skew = 2;
double xc = 300;
double yc = 350;
/**/
double[] radial = new /**/
double[] { 0.12, -0.13 };
Point2D_F64 point = new Point2D_F64();
double undistX = 19.5;
double undistY = 200.1;
AddRadialPtoN_F64 p_to_n = new AddRadialPtoN_F64().setK(fx, fy, skew, xc, yc).setDistortion(radial, t1, t2);
new Transform2ThenPixel_F64(p_to_n).set(fx, fy, skew, xc, yc).compute(undistX, undistY, point);
double distX = point.x;
double distY = point.y;
RemoveRadialPtoN_F64 alg = new RemoveRadialPtoN_F64().setK(fx, fy, skew, xc, yc).setDistortion(radial, t1, t2);
alg.compute(distX, distY, point);
// / go from calibrated coordinates to pixel
DMatrixRMaj K = PerspectiveOps.calibrationMatrix(fx, fy, skew, xc, yc);
GeometryMath_F64.mult(K, point, point);
assertEquals(undistX, point.x, GrlConstants.TEST_SQ_F64);
assertEquals(undistY, point.y, GrlConstants.TEST_SQ_F64);
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class CalibrateStereoPlanarGuiApp method setRectification.
/**
* Computes stereo rectification and then passes the distortion along to the gui.
*/
private void setRectification(final StereoParameters param) {
// calibration matrix for left and right camera
DMatrixRMaj K1 = PerspectiveOps.calibrationMatrix(param.getLeft(), (DMatrixRMaj) null);
DMatrixRMaj K2 = PerspectiveOps.calibrationMatrix(param.getRight(), (DMatrixRMaj) null);
RectifyCalibrated rectify = RectifyImageOps.createCalibrated();
rectify.process(K1, new Se3_F64(), K2, param.getRightToLeft().invert(null));
final DMatrixRMaj rect1 = rectify.getRect1();
final DMatrixRMaj rect2 = rectify.getRect2();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
gui.setRectification(param.getLeft(), rect1, param.getRight(), rect2);
}
});
gui.repaint();
}
Aggregations