public PixelTransformCached_F32(int width, int height, Point2Transform2_F32 transform ) { this(width,height, new PointToPixelTransform_F32(transform)); }
@Override public void handleAlgorithmChange() { alg = FactoryDistort.deformMls(control.getConfigMLS()); p2p.setTransform(alg); alg.setImageShape(undistorted.width,undistorted.height); controlPointsModified(); }
/** * Used to manually specify a transform. From output to input */ public FDistort transform( Point2Transform2_F32 outputToInput ) { return transform( new PointToPixelTransform_F32(outputToInput)); }
@Override public void processImage(int sourceID, long frameID, BufferedImage buffered, ImageBase input) { synchronized (imageLock) { // create a copy of the input image for output purposes if (buffFisheye.getWidth() != buffered.getWidth() || buffFisheye.getHeight() != buffered.getHeight()) { buffFisheye = new BufferedImage(buffered.getWidth(), buffered.getHeight(), BufferedImage.TYPE_INT_BGR); panelFisheye.setPreferredSize(new Dimension(buffered.getWidth(),buffered.getHeight())); panelFisheye.setImageUI(buffFisheye); distortImage.setModel(new PointToPixelTransform_F32(distorter)); } buffFisheye.createGraphics().drawImage(buffered, 0, 0, null); fisheye.setTo((T)input); rerenderPinhole(); } }
public static void fullViewLeft(int imageWidth,int imageHeight, FMatrixRMaj rectifyLeft, FMatrixRMaj rectifyRight ) { Point2Transform2_F32 tranLeft = new PointTransformHomography_F32(rectifyLeft); RectangleLength2D_F32 bound = DistortImageOps.boundBox_F32(imageWidth, imageHeight, new PointToPixelTransform_F32(tranLeft)); float scaleX = imageWidth/bound.width; float scaleY = imageHeight/bound.height; float scale = (float)Math.min(scaleX,scaleY); adjustUncalibrated(rectifyLeft, rectifyRight, bound, scale); }
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); }
/** * <p> * Adjust the rectification such that only pixels which overlap the original left image can be seen. For use with * uncalibrated images with unknown baselines. Image processing is easier since only the "true" image pixels * are visible, but information along the image border has been discarded. The rectification matrices are * overwritten with adjusted values on output. * </p> * * @param imageWidth Width of left image. * @param imageHeight Height of left image. * @param rectifyLeft Rectification matrix for left image. Input and Output. Modified. * @param rectifyRight Rectification matrix for right image. Input and Output. Modified. */ public static void allInsideLeft( int imageWidth,int imageHeight, DenseMatrix64F rectifyLeft, DenseMatrix64F rectifyRight ) { Point2Transform2_F32 tranLeft = new PointTransformHomography_F32(rectifyLeft); RectangleLength2D_F32 bound = LensDistortionOps.boundBoxInside(imageWidth, imageHeight, new PointToPixelTransform_F32(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 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); }
@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(); }
/** * <p> * Adjust the rectification such that the entire original left image can be seen. For use with * uncalibrated stereo images with unknown baseline. * </p> * * <p> * Input rectification matrices are overwritten with adjusted values on output. * </p> * * @param imageWidth Width of left image. * @param imageHeight Height of left image. * @param rectifyLeft Rectification matrix for left image. Input and Output. Modified. * @param rectifyRight Rectification matrix for right image. Input and Output. Modified. */ // TODO Delete this function? It should reasonably fill the old view in most non-pathological cases public static void fullViewLeft(int imageWidth,int imageHeight, DenseMatrix64F rectifyLeft, DenseMatrix64F rectifyRight ) { Point2Transform2_F32 tranLeft = new PointTransformHomography_F32(rectifyLeft); RectangleLength2D_F32 bound = DistortImageOps.boundBox_F32(imageWidth, imageHeight, new PointToPixelTransform_F32(tranLeft)); double scaleX = imageWidth/bound.width; double scaleY = imageHeight/bound.height; double scale = Math.min(scaleX,scaleY); adjustUncalibrated(rectifyLeft, rectifyRight, bound, scale); }
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); }
/** * Specifies the image's intrinsic parameters and target size * * @param distortion Lens distortion * @param width Image width * @param height Image height * @param cache If there's lens distortion should it cache the transforms? Speeds it up by about 12%. Ignored * if no lens distortion */ public void configure(LensDistortionNarrowFOV distortion, int width , int height , boolean cache ) { Point2Transform2_F32 pointSquareToInput; Point2Transform2_F32 pointDistToUndist = distortion.undistort_F32(true,true); Point2Transform2_F32 pointUndistToDist = distortion.distort_F32(true,true); PixelTransform2_F32 distToUndist = new PointToPixelTransform_F32(pointDistToUndist); PixelTransform2_F32 undistToDist = new PointToPixelTransform_F32(pointUndistToDist); if( cache ) { distToUndist = new PixelTransformCached_F32(width, height, distToUndist); undistToDist = new PixelTransformCached_F32(width, height, undistToDist); } squareDetector.setLensDistortion(width, height,distToUndist,undistToDist); pointSquareToInput = new SequencePoint2Transform2_F32(transformHomography,pointUndistToDist); // provide intrinsic camera parameters PixelTransform2_F32 squareToInput= new PointToPixelTransform_F32(pointSquareToInput); removePerspective.setModel(squareToInput); this.undistToDist = distortion.distort_F64(true,true); }
/** * Easy way to create {@link ImageDistort} given {@link PixelTransform2_F32}. To improve * performance the distortion is automatically cached. * * @see FactoryDistort * @see FactoryInterpolation * * @deprecated As of v0.19. Use {@link FDistort} instead * * @param transform Image transform. * @param interpType Which interpolation. Try bilinear. * @param inputType Image of single band image it will process. * @return The {@link ImageDistort} */ public static <Input extends ImageGray<Input>,Output extends ImageGray<Output>> ImageDistort<Input,Output> createImageDistort(Point2Transform2_F32 transform, InterpolationType interpType, BorderType borderType, Class<Input> inputType, Class<Output> outputType) { InterpolatePixelS<Input> interp = FactoryInterpolation.createPixelS(0, 255, interpType,borderType, inputType); ImageDistort<Input,Output> distorter = FactoryDistort.distortSB(true, interp, outputType); distorter.setModel(new PointToPixelTransform_F32(transform)); return distorter; }
if( type == AdjustmentType.FULL_VIEW ) { bound = DistortImageOps.boundBox_F32(param.width, param.height, new PointToPixelTransform_F32(remove_p_to_p)); } else if( type == AdjustmentType.EXPAND) { bound = LensDistortionOps.boundBoxInside(param.width, param.height, new PointToPixelTransform_F32(remove_p_to_p));
new PointToPixelTransform_F32(tranLeft));
new PointToPixelTransform_F32(equiToCamera));
/** * <p> * Adjust the rectification such that only pixels which overlap the original left image can be seen. For use with * calibrated stereo images having a known baseline. Image processing is easier since only the "true" image pixels * are visible, but information along the image border has been discarded. The rectification matrices are * overwritten with adjusted values on output. * </p> * * @param paramLeft Intrinsic parameters for left camera. Not modified. * @param rectifyLeft Rectification matrix for left image. Input and Output. Modified. * @param rectifyRight Rectification matrix for right image. Input and Output. Modified. * @param rectifyK Rectification calibration matrix. Input and Output. Modified. */ public static void allInsideLeft(CameraPinholeRadial paramLeft, DenseMatrix64F rectifyLeft, DenseMatrix64F rectifyRight, DenseMatrix64F 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_F32(paramLeft, rectifyLeft); RectangleLength2D_F32 bound = LensDistortionOps.boundBoxInside(paramLeft.width, paramLeft.height, new PointToPixelTransform_F32(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); }
distortImage.setModel(new PointToPixelTransform_F32(distorter));
new PointToPixelTransform_F32(equiToCamera));
new PointToPixelTransform_F32(equiToCamera));