use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class TestZhang99OptimizationFunction method estimate.
protected static CalibrationObservation estimate(Zhang99AllParam param, Zhang99AllParam.View v, List<Point2D_F64> grid) {
CalibrationObservation ret = new CalibrationObservation();
Se3_F64 se = new Se3_F64();
Point3D_F64 cameraPt = new Point3D_F64();
Point2D_F64 calibratedPt = new Point2D_F64();
ConvertRotation3D_F64.rodriguesToMatrix(v.rotation, se.getR());
se.T = v.T;
CameraPinholeRadial intrinsic = param.getIntrinsic().getCameraModel();
for (int i = 0; i < grid.size(); i++) {
Point2D_F64 gridPt = grid.get(i);
// Put the point in the camera's reference frame
SePointOps_F64.transform(se, new Point3D_F64(gridPt.x, gridPt.y, 0), cameraPt);
// calibrated pixel coordinates
calibratedPt.x = cameraPt.x / cameraPt.z;
calibratedPt.y = cameraPt.y / cameraPt.z;
// apply radial distortion
CalibrationPlanarGridZhang99.applyDistortion(calibratedPt, intrinsic.radial, intrinsic.t1, intrinsic.t2);
// convert to pixel coordinates
double x = intrinsic.fx * calibratedPt.x + intrinsic.skew * calibratedPt.y + intrinsic.cx;
double y = intrinsic.fy * calibratedPt.y + intrinsic.cy;
ret.add(new Point2D_F64(x, y), i);
}
return ret;
}
use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class MonoPlanarPanel method setCalibration.
@Override
public void setCalibration(Zhang99AllParam found) {
CameraPinholeRadial intrinsic = (CameraPinholeRadial) found.getIntrinsic().getCameraModel();
String textX = String.format("%5.1f", intrinsic.cx);
String textY = String.format("%5.1f", intrinsic.cy);
paramCenterX.setText(textX);
paramCenterY.setText(textY);
String textA = String.format("%5.1f", intrinsic.fx);
String textB = String.format("%5.1f", intrinsic.fy);
paramFX.setText(textA);
paramFY.setText(textB);
if (intrinsic.skew == 0) {
paramSkew.setText("");
} else {
String textC = String.format("%5.1e", intrinsic.skew);
paramSkew.setText(textC);
}
String radial = "";
if (intrinsic.radial != null) {
for (int i = 0; i < intrinsic.radial.length; i++) {
radial += String.format("%5.2e", intrinsic.radial[i]);
if (i != intrinsic.radial.length - 1) {
radial += "\n";
}
}
}
paramRadial.setText(radial);
if (intrinsic.t1 != 0 && intrinsic.t2 != 0)
paramTangental.setText(String.format("%5.2e\n%5.2e", intrinsic.t1, intrinsic.t2));
else
paramTangental.setText("");
}
use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class ImplRectifyImageOps_F32 method fullViewLeft.
public static void fullViewLeft(CameraPinholeRadial paramLeft, FMatrixRMaj rectifyLeft, FMatrixRMaj rectifyRight, FMatrixRMaj rectifyK) {
// need to take in account the order in which image distort will remove rectification later on
paramLeft = new CameraPinholeRadial(paramLeft);
Point2Transform2_F32 tranLeft = transformPixelToRect(paramLeft, rectifyLeft);
RectangleLength2D_F32 bound = DistortImageOps.boundBox_F32(paramLeft.width, paramLeft.height, new PointToPixelTransform_F32(tranLeft));
float scaleX = paramLeft.width / bound.width;
float scaleY = paramLeft.height / bound.height;
float scale = (float) Math.min(scaleX, scaleY);
adjustCalibrated(rectifyLeft, rectifyRight, rectifyK, bound, scale);
}
use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class ImplRectifyImageOps_F64 method fullViewLeft.
public static void fullViewLeft(CameraPinholeRadial paramLeft, DMatrixRMaj rectifyLeft, DMatrixRMaj rectifyRight, DMatrixRMaj rectifyK) {
// need to take in account the order in which image distort will remove rectification later on
paramLeft = new CameraPinholeRadial(paramLeft);
Point2Transform2_F64 tranLeft = transformPixelToRect(paramLeft, rectifyLeft);
RectangleLength2D_F64 bound = DistortImageOps.boundBox_F64(paramLeft.width, paramLeft.height, new PointToPixelTransform_F64(tranLeft));
double scaleX = paramLeft.width / bound.width;
double scaleY = paramLeft.height / bound.height;
double scale = Math.min(scaleX, scaleY);
adjustCalibrated(rectifyLeft, rectifyRight, rectifyK, bound, scale);
}
use of boofcv.struct.calib.CameraPinholeRadial in project BoofCV by lessthanoptimal.
the class ImplRectifyImageOps_F64 method allInsideLeft.
public static void allInsideLeft(CameraPinholeRadial paramLeft, DMatrixRMaj rectifyLeft, DMatrixRMaj rectifyRight, DMatrixRMaj rectifyK) {
// need to take in account the order in which image distort will remove rectification later on
paramLeft = new CameraPinholeRadial(paramLeft);
Point2Transform2_F64 tranLeft = transformPixelToRect(paramLeft, rectifyLeft);
RectangleLength2D_F64 bound = LensDistortionOps.boundBoxInside(paramLeft.width, paramLeft.height, new PointToPixelTransform_F64(tranLeft));
LensDistortionOps.roundInside(bound);
double scaleX = paramLeft.width / (double) bound.width;
double scaleY = paramLeft.height / (double) bound.height;
double scale = Math.max(scaleX, scaleY);
adjustCalibrated(rectifyLeft, rectifyRight, rectifyK, bound, scale);
}
Aggregations