/** * Creates an identical image. Note that if this image is a sub-image portions of hte image which are not part * of the sub-image are not copied. * * @return Clone of this image. */ @SuppressWarnings({"unchecked", "CloneDoesntDeclareCloneNotSupportedException", "CloneDoesntCallSuperClone"}) @Override public T clone() { T ret = createSameShape(); ret.setTo((T)this); return ret; } }
/** * Configuration constructor * @param distort Used to apply image distortion from different input images * @param equiWidth Width of output equirectangular image * @param equiHeight Height of output equirectangular image * @param imageType Type of image it processes and outputs. Must be floating point. Hmm why isn't this fixed? */ public MultiCameraToEquirectangular(ImageDistort<T,T> distort , int equiWidth , int equiHeight , ImageType<T> imageType ) { if( imageType.getDataType().isInteger() || imageType.getDataType().getNumBits() != 32 ) throw new IllegalArgumentException("Must be a 32 bit floating point image"); this.distort = distort; this.equiWidth = equiWidth; this.equHeight = equiHeight; tools.configure(equiWidth, equiHeight); weightImage = new GrayF32(equiWidth,equiHeight); averageImage = imageType.createImage(equiWidth, equiHeight); workImage = averageImage.createSameShape(); cameraRendered = averageImage.createSameShape(); }
/** * Configuration constructor * @param distort Used to apply image distortion from different input images * @param equiWidth Width of output equirectangular image * @param equiHeight Height of output equirectangular image * @param imageType Type of image it processes and outputs. Must be floating point. Hmm why isn't this fixed? */ public MultiCameraToEquirectangular(ImageDistort<T,T> distort , int equiWidth , int equiHeight , ImageType<T> imageType ) { if( imageType.getDataType().isInteger() || imageType.getDataType().getNumBits() != 32 ) throw new IllegalArgumentException("Must be a 32 bit floating point image"); this.distort = distort; this.equiWidth = equiWidth; this.equHeight = equiHeight; tools.configure(equiWidth, equiHeight); weightImage = new GrayF32(equiWidth,equiHeight); averageImage = imageType.createImage(equiWidth, equiHeight); workImage = averageImage.createSameShape(); cameraRendered = averageImage.createSameShape(); }
@Override public void processImage(int sourceID, long frameID, BufferedImage buffered, final ImageBase undistorted) { // do this here instead of a reshape to ensure the number of bands is the same distorted = (T)undistorted.createSameShape(); BufferedImage tmp = distortedBuff; distortedBuff = ConvertBufferedImage.checkDeclare( undistorted.width,undistorted.height,distortedBuff,buffered.getType()); if( tmp != distortedBuff ) { distorted.reshape(undistorted.width, undistorted.height); this.undistorted.reshape(undistorted.width, undistorted.height); gui.setPreferredSize(new Dimension(undistorted.width,undistorted.height)); alg.setImageShape(undistorted.width,undistorted.height); synchronized (pointsUndistorted){ validTransform = false; pointsUndistorted.clear(); pointsDistorted.clear(); } } if( inputMethod == InputMethod.IMAGE ) { this.undistorted.setTo((T)undistorted); } renderDistorted(buffered, (T)undistorted); }
@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); }