public static void fullViewLeft(int imageWidth,int imageHeight, DMatrixRMaj rectifyLeft, DMatrixRMaj rectifyRight ) { Point2Transform2_F64 tranLeft = new PointTransformHomography_F64(rectifyLeft); RectangleLength2D_F64 bound = DistortImageOps.boundBox_F64(imageWidth, imageHeight, new PointToPixelTransform_F64(tranLeft)); double scaleX = imageWidth/bound.width; double scaleY = imageHeight/bound.height; double scale = Math.min(scaleX,scaleY); adjustUncalibrated(rectifyLeft, rectifyRight, bound, scale); }
public PointTransformHomography_F64(Homography2D_F64 homo) { set(homo); }
public static void allInsideLeft( int imageWidth,int imageHeight, DMatrixRMaj rectifyLeft, DMatrixRMaj rectifyRight ) { PointTransformHomography_F64 tranLeft = new PointTransformHomography_F64(rectifyLeft); RectangleLength2D_F64 bound = LensDistortionOps_F64.boundBoxInside(imageWidth, imageHeight, new PointToPixelTransform_F64(tranLeft)); double scaleX = imageWidth/(double)bound.width; double scaleY = imageHeight/(double)bound.height; double scale = Math.max(scaleX, scaleY); adjustUncalibrated(rectifyLeft, rectifyRight, bound, scale); }
public static Point2Transform2_F64 transformPixelToRect(CameraPinholeRadial param, DMatrixRMaj rectify) { Point2Transform2_F64 remove_p_to_p = narrow(param).undistort_F64(true, true); PointTransformHomography_F64 rectifyDistort = new PointTransformHomography_F64(rectify); return new SequencePoint2Transform2_F64(remove_p_to_p,rectifyDistort); }
/** * <p> * Creates a transform that applies rectification to unrectified distorted pixels. * </p> * * @param param Intrinsic parameters. Not modified. * @param rectify Transform for rectifying the image. Not modified. * @return Transform from distorted pixel to rectified pixels */ public static Point2Transform2_F64 transformPixelToRect_F64(CameraPinholeRadial param, DenseMatrix64F rectify) { Point2Transform2_F64 remove_p_to_p = transformPoint(param).undistort_F64(true, true); PointTransformHomography_F64 rectifyDistort = new PointTransformHomography_F64(rectify); return new SequencePoint2Transform2_F64(remove_p_to_p,rectifyDistort); }
/** * Given the lens distortion and the intrinsic adjustment matrix compute the new intrinsic parameters * and {@link Point2Transform2_F32} */ private static Point2Transform2_F64 adjustmentTransform_F64(CameraPinholeRadial param, CameraPinholeRadial paramAdj, boolean adjToDistorted, Point2Transform2_F64 remove_p_to_p, DenseMatrix64F A) { DenseMatrix64F A_inv = null; if( !adjToDistorted || paramAdj != null ) { A_inv = new DenseMatrix64F(3, 3); if (!CommonOps.invert(A, A_inv)) { throw new RuntimeException("Failed to invert adjustment matrix. Probably bad."); } } if( paramAdj != null ) { PerspectiveOps.adjustIntrinsic(param, A_inv, paramAdj); } if( adjToDistorted ) { Point2Transform2_F64 add_p_to_p = transformPoint(param).distort_F64(true, true); PointTransformHomography_F64 adjust = new PointTransformHomography_F64(A); return new SequencePoint2Transform2_F64(adjust,add_p_to_p); } else { PointTransformHomography_F64 adjust = new PointTransformHomography_F64(A_inv); return new SequencePoint2Transform2_F64(remove_p_to_p,adjust); } }
public static Point2Transform2_F64 transformRectToPixel(CameraPinholeRadial param, DMatrixRMaj rectify) { Point2Transform2_F64 add_p_to_p = narrow(param).distort_F64(true, true); DMatrixRMaj rectifyInv = new DMatrixRMaj(3,3); CommonOps_DDRM.invert(rectify,rectifyInv); PointTransformHomography_F64 removeRect = new PointTransformHomography_F64(rectifyInv); return new SequencePoint2Transform2_F64(removeRect,add_p_to_p); }
/** * <p> * Creates a transform that goes from rectified to original distorted pixel coordinates. * Rectification includes removal of lens distortion. Used for rendering rectified images. * </p> * * @param param Intrinsic parameters. * @param rectify Transform for rectifying the image. * @return Transform from rectified to unrectified pixels */ public static Point2Transform2_F64 transformRectToPixel_F64(CameraPinholeRadial param, DenseMatrix64F rectify) { Point2Transform2_F64 add_p_to_p = transformPoint(param).distort_F64(true, true); DenseMatrix64F rectifyInv = new DenseMatrix64F(3,3); CommonOps.invert(rectify,rectifyInv); PointTransformHomography_F64 removeRect = new PointTransformHomography_F64(rectifyInv); return new SequencePoint2Transform2_F64(removeRect,add_p_to_p); }
public static Point2Transform2_F64 transformPixelToRectNorm(CameraPinholeRadial param, DMatrixRMaj rectify, DMatrixRMaj rectifyK) { if (rectifyK.get(0, 1) != 0) throw new IllegalArgumentException("Skew should be zero in rectified images"); Point2Transform2_F64 remove_p_to_p = narrow(param).undistort_F64(true, true); PointTransformHomography_F64 rectifyDistort = new PointTransformHomography_F64(rectify); PinholePtoN_F64 pixelToNorm = new PinholePtoN_F64(); pixelToNorm.set(rectifyK.get(0, 0), rectifyK.get(1, 1), rectifyK.get(0, 1), rectifyK.get(0, 2), rectifyK.get(1, 2)); return new SequencePoint2Transform2_F64(remove_p_to_p, rectifyDistort, pixelToNorm); }
Point2Transform2_F64 des_p_to_n = desired.undistort_F64(true, false); Point2Transform2_F64 ori_n_to_p = original.distort_F64(false, true); PointTransformHomography_F64 adjust = new PointTransformHomography_F64(A); return new SequencePoint2Transform2_F64(adjust,des_p_to_n,ori_n_to_p); } else { PointTransformHomography_F64 adjust = new PointTransformHomography_F64(A_inv); return new SequencePoint2Transform2_F64(ori_to_des, adjust);
/** * <p> * Creates a transform that applies rectification to unrectified distorted pixels and outputs * normalized pixel coordinates. * </p> * * @param param Intrinsic parameters. * @param rectify Transform for rectifying the image. * @param rectifyK Camera calibration matrix after rectification * @return Transform from unrectified to rectified normalized pixels */ public static Point2Transform2_F64 transformPixelToRectNorm_F64(CameraPinholeRadial param, DenseMatrix64F rectify, DenseMatrix64F rectifyK) { if (rectifyK.get(0, 1) != 0) throw new IllegalArgumentException("Skew should be zero in rectified images"); Point2Transform2_F64 remove_p_to_p = transformPoint(param).undistort_F64(true, true); PointTransformHomography_F64 rectifyDistort = new PointTransformHomography_F64(rectify); PinholePtoN_F64 pixelToNorm = new PinholePtoN_F64(); pixelToNorm.set(rectifyK.get(0, 0), rectifyK.get(1, 1), rectifyK.get(0, 1), rectifyK.get(0, 2), rectifyK.get(1, 2)); return new SequencePoint2Transform2_F64(remove_p_to_p, rectifyDistort, pixelToNorm); }