@Override public void processImage(int sourceID, long frameID, final BufferedImage buffered, ImageBase input) { // strip away distortion parameters CameraPinhole desired = new CameraPinhole(param); // distorted image dist = (T)input.clone(); // storage for undistorted image undist = (T)input.createSameShape(); // show results and draw a horizontal line where the user clicks to see rectification easier SwingUtilities.invokeLater(() -> { gui.reset(); gui.addItem(new ImagePanel(buffered), "Original"); }); // add different types of adjustments Point2Transform2_F32 add_p_to_p = LensDistortionOps_F32.transformChangeModel(AdjustmentType.NONE, param,desired,true,null); addUndistorted("No Adjustment", add_p_to_p); Point2Transform2_F32 expand = LensDistortionOps_F32.transformChangeModel(AdjustmentType.EXPAND, param,desired, true, null); addUndistorted("Expand", expand); Point2Transform2_F32 fullView = LensDistortionOps_F32.transformChangeModel(AdjustmentType.FULL_VIEW,param, desired,true, null); addUndistorted("Full View", fullView); Point2Transform2_F32 center = LensDistortionOps_F32.transformChangeModel(AdjustmentType.CENTER,param, desired,true, null); addUndistorted("Center", center); }
public static void allInsideLeft(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 = LensDistortionOps_F32.boundBoxInside(paramLeft.width, paramLeft.height, new PointToPixelTransform_F32(tranLeft)); LensDistortionOps_F32.roundInside(bound); float scaleX = paramLeft.width/(float)bound.width; float scaleY = paramLeft.height/(float)bound.height; float scale = (float)Math.max(scaleX, scaleY); adjustCalibrated(rectifyLeft, rectifyRight, rectifyK, bound, scale); }
PixelTransform2_F32 transform) List<Point2D_F32> points = computeBoundingPoints(srcWidth, srcHeight, transform); Point2D_F32 center = new Point2D_F32(); UtilPoint2D_F32.mean(points,center);
bound = DistortImageOps.boundBox_F32(paramOriginal.width, paramOriginal.height, new PointToPixelTransform_F32(ori_to_des)); } else if( type == AdjustmentType.EXPAND) { bound = LensDistortionOps_F32.boundBoxInside(paramOriginal.width, paramOriginal.height, new PointToPixelTransform_F32(ori_to_des)); LensDistortionOps_F32.roundInside(bound); } else if( type == AdjustmentType.CENTER) { bound = LensDistortionOps_F32.centerBoxInside(paramOriginal.width, paramOriginal.height, new PointToPixelTransform_F32(ori_to_des)); } else if( type == AdjustmentType.NONE ) { bound = new RectangleLength2D_F32(0,0,paramDesired.width, paramDesired.height);
public static void allInsideLeft( int imageWidth,int imageHeight, FMatrixRMaj rectifyLeft, FMatrixRMaj rectifyRight ) { PointTransformHomography_F32 tranLeft = new PointTransformHomography_F32(rectifyLeft); RectangleLength2D_F32 bound = LensDistortionOps_F32.boundBoxInside(imageWidth, imageHeight, new PointToPixelTransform_F32(tranLeft)); float scaleX = imageWidth/(float)bound.width; float scaleY = imageHeight/(float)bound.height; float scale = (float)Math.max(scaleX, scaleY); adjustUncalibrated(rectifyLeft, rectifyRight, bound, scale); }
@Override public synchronized void updatedPinholeModel(CameraPinholeRadial desired) { if( undist.width != desired.width || undist.height != desired.height ) { undist.reshape(desired.width, desired.height); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { gui.setPreferredSize(new Dimension(undist.width, undist.height)); // gui.invalidate(); } }); } Point2Transform2_F32 add_p_to_p = LensDistortionOps_F32. transformChangeModel(adjustment, origModel,desired,true,null); undistorter.setModel(new PointToPixelTransform_F32(add_p_to_p)); if( inputMethod == InputMethod.IMAGE ) renderCameraModel(); }
PixelTransform2_F32 transform) { List<Point2D_F32> points = computeBoundingPoints(srcWidth, srcHeight, transform);
@Override public void setCalibration (CameraPinholeRadial param ) { CameraPinhole undistorted = new CameraPinhole(param); this.undoRadial = LensDistortionOps.changeCameraModel( AdjustmentType.FULL_VIEW, BorderType.ZERO, param, undistorted,null, ImageType.single(GrayF32.class)); this.remove_p_to_p = LensDistortionOps_F32.transformChangeModel(AdjustmentType.FULL_VIEW, param, undistorted, false,null); undoRadialDistortion(distorted); }
Point2Transform2_F32 undistToDist = LensDistortionOps_F32.transformChangeModel(type, original, desired, true, modified);