@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); }
@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(); }
@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);