use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class StereoProcessingBase method setCalibration.
/**
* Specifies stereo parameters
*
* @param stereoParam stereo parameters
*/
public void setCalibration(StereoParameters stereoParam) {
CameraPinholeRadial left = stereoParam.getLeft();
CameraPinholeRadial right = stereoParam.getRight();
// adjust image size
imageLeftRect.reshape(left.getWidth(), left.getHeight());
imageRightRect.reshape(right.getWidth(), right.getHeight());
// compute rectification
RectifyCalibrated rectifyAlg = RectifyImageOps.createCalibrated();
Se3_F64 leftToRight = stereoParam.getRightToLeft().invert(null);
// original camera calibration matrices
DMatrixRMaj K1 = PerspectiveOps.calibrationMatrix(left, (DMatrixRMaj) null);
DMatrixRMaj K2 = PerspectiveOps.calibrationMatrix(right, (DMatrixRMaj) null);
rectifyAlg.process(K1, new Se3_F64(), K2, leftToRight);
// rectification matrix for each image
rect1 = rectifyAlg.getRect1();
rect2 = rectifyAlg.getRect2();
// New calibration and rotation matrix, Both cameras are the same after rectification.
rectK = rectifyAlg.getCalibrationMatrix();
rectR = rectifyAlg.getRectifiedRotation();
FMatrixRMaj rect1_F32 = new FMatrixRMaj(3, 3);
FMatrixRMaj rect2_F32 = new FMatrixRMaj(3, 3);
ConvertMatrixData.convert(rect1, rect1_F32);
ConvertMatrixData.convert(rect2, rect2_F32);
ImageType<T> imageType = imageLeftRect.getImageType();
distortLeftRect = RectifyImageOps.rectifyImage(stereoParam.left, rect1_F32, BorderType.SKIP, imageType);
distortRightRect = RectifyImageOps.rectifyImage(stereoParam.right, rect2_F32, BorderType.SKIP, imageType);
// Compute parameters that are needed when converting to 3D
baseline = stereoParam.getBaseline();
fx = rectK.get(0, 0);
fy = rectK.get(1, 1);
cx = rectK.get(0, 2);
cy = rectK.get(1, 2);
}
Aggregations