Search in sources :

Example 61 with CameraPinholeRadial

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;
}
Also used : Point3D_F64(georegression.struct.point.Point3D_F64) Point2D_F64(georegression.struct.point.Point2D_F64) CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) Se3_F64(georegression.struct.se.Se3_F64)

Example 62 with CameraPinholeRadial

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("");
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial)

Example 63 with CameraPinholeRadial

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);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) PointToPixelTransform_F32(boofcv.alg.distort.PointToPixelTransform_F32) RectangleLength2D_F32(georegression.struct.shapes.RectangleLength2D_F32) SequencePoint2Transform2_F32(boofcv.struct.distort.SequencePoint2Transform2_F32) Point2Transform2_F32(boofcv.struct.distort.Point2Transform2_F32)

Example 64 with CameraPinholeRadial

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);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) SequencePoint2Transform2_F64(boofcv.struct.distort.SequencePoint2Transform2_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) PointToPixelTransform_F64(boofcv.alg.distort.PointToPixelTransform_F64) RectangleLength2D_F64(georegression.struct.shapes.RectangleLength2D_F64)

Example 65 with CameraPinholeRadial

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);
}
Also used : CameraPinholeRadial(boofcv.struct.calib.CameraPinholeRadial) SequencePoint2Transform2_F64(boofcv.struct.distort.SequencePoint2Transform2_F64) Point2Transform2_F64(boofcv.struct.distort.Point2Transform2_F64) PointToPixelTransform_F64(boofcv.alg.distort.PointToPixelTransform_F64) RectangleLength2D_F64(georegression.struct.shapes.RectangleLength2D_F64)

Aggregations

CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)81 Test (org.junit.Test)37 Se3_F64 (georegression.struct.se.Se3_F64)26 GrayF32 (boofcv.struct.image.GrayF32)19 Point2D_F64 (georegression.struct.point.Point2D_F64)16 File (java.io.File)15 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)12 BufferedImage (java.awt.image.BufferedImage)12 DMatrixRMaj (org.ejml.data.DMatrixRMaj)12 Point2Transform2_F32 (boofcv.struct.distort.Point2Transform2_F32)10 LensDistortionRadialTangential (boofcv.alg.distort.radtan.LensDistortionRadialTangential)9 CameraPinhole (boofcv.struct.calib.CameraPinhole)9 Point3D_F64 (georegression.struct.point.Point3D_F64)8 ArrayList (java.util.ArrayList)7 SimulatePlanarWorld (boofcv.simulation.SimulatePlanarWorld)6 StereoParameters (boofcv.struct.calib.StereoParameters)6 Point2Transform2_F64 (boofcv.struct.distort.Point2Transform2_F64)6 Point2D_F32 (georegression.struct.point.Point2D_F32)5 FMatrixRMaj (org.ejml.data.FMatrixRMaj)5 GrayU8 (boofcv.struct.image.GrayU8)4