congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
ImageDistort.setModel
Code IndexAdd Tabnine to your IDE (free)

How to use
setModel
method
in
boofcv.alg.distort.ImageDistort

Best Java code snippets using boofcv.alg.distort.ImageDistort.setModel (Showing top 20 results out of 315)

origin: org.boofcv/boofcv-ip

@Override
public void setModel(PixelTransform2_F32 dstToSrc) {
  layerDistort.setModel(dstToSrc);
}
origin: org.boofcv/demonstrations

@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 (buffEqui.getWidth() != buffered.getWidth() || buffEqui.getHeight() != buffered.getHeight()) {
      buffEqui = new BufferedImage(buffered.getWidth(), buffered.getHeight(), BufferedImage.TYPE_INT_BGR);
      panelEqui.setPreferredSize(new Dimension(buffered.getWidth(), buffered.getHeight()));
      panelEqui.setImageUI(buffEqui);
      distorter.setEquirectangularShape(input.width, input.height);
      distortImage.setModel(distorter);
    }
    buffEqui.createGraphics().drawImage(buffered, 0, 0, null);
    equi.setTo((T)input);
    rerenderPinhole();
  }
}
origin: org.boofcv/demonstrations

@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();
  }
}
origin: org.boofcv/demonstrations

@Override
protected void handleInputChange(int source, InputMethod method, int width, int height) {
  super.handleInputChange(source, method, width, height);
  if( rendered.getWidth() != width || rendered.getHeight() != height ) {
    rendered = new BufferedImage(width,height,BufferedImage.TYPE_INT_BGR);
    panelImage.setPreferredSize(new Dimension(width,height));
    distorter.setEquirectangularShape(width, height);
    distortImage.setModel(distorter); // let it know the transform has changed
  }
  centerLon = centerLat = 0;
  distorted.reshape(width,height);
  distorter.setEquirectangularShape(width,height);
}
origin: org.boofcv/boofcv-ip

  /**
   * Creates a {@link boofcv.alg.distort.ImageDistort} for the planar images of the specified image type, transformation
   * and interpolation instance.
   *
   * @param dstToSrc Transform from dst to src image.
   * @param interp Which interpolation algorithm should be used.
   */
  public static <Input extends ImageGray<Input>,Output extends ImageGray<Output>>
  ImageDistort<Planar<Input>,Planar<Output>>
  createDistortPL(Class<Output> outputType, PixelTransform2_F32 dstToSrc,
          InterpolatePixelS<Input> interp, boolean cached )
  {
    ImageDistort<Input,Output> bandDistort = FactoryDistort.distortSB(cached, interp, outputType);
    bandDistort.setModel(dstToSrc);
    return new ImplImageDistort_PL<>(bandDistort);
  }
}
origin: org.boofcv/boofcv-ip

/**
 * Applies a pixel transform to a single band image.  More flexible but order to use function.
 *
 * @deprecated As of v0.19.  Use {@link FDistort} instead
 *
 * @param input Input (source) image.
 * @param output Where the result of transforming the image image is written to.
 * @param renderAll true it renders all pixels, even ones outside the input image.
 * @param transform The transform that is being applied to the image
 * @param interp Interpolation algorithm.
 */
public static <Input extends ImageGray<Input>,Output extends ImageGray<Output>>
void distortSingle(Input input, Output output,
          boolean renderAll, PixelTransform2_F32 transform,
          InterpolatePixelS<Input> interp)
{
  Class<Output> inputType = (Class<Output>)input.getClass();
  ImageDistort<Input,Output> distorter = FactoryDistort.distortSB(false, interp, inputType);
  distorter.setRenderAll(renderAll);
  distorter.setModel(transform);
  distorter.apply(input,output);
}
origin: org.boofcv/demonstrations

@Override
public void updateCylinder(int width, int height, double vfov) {
  synchronized (distorter) {
    distorter.configure(width,height,(float)UtilAngle.radian(vfov));
    distortImage.setModel(distorter); // let it know the transform has changed
    if( distorted.width != width || distorted.height != height ) {
      rendered = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
      distorted.reshape(width, height);
    }
    if (inputMethod == InputMethod.IMAGE) {
      renderOutput(inputCopy);
    }
  }
}
origin: org.boofcv/recognition

/**
 * Configuration constructor
 * @param clip If true it will first clip the image to make it square before reducing it's size.  Otherwise both
 *             sides are scaled independently to make it square
 * @param imageType Type of image it iwll be processing
 */
public ClipAndReduce( boolean clip , ImageType<T> imageType ) {
  this.clip = clip;
  InterpolatePixel<T> interp =
      FactoryInterpolation.createPixel(0,255, InterpolationType.BILINEAR, BorderType.EXTENDED,imageType);
  distort = FactoryDistort.distort(false,interp,imageType);
  distort.setModel(new PixelTransformAffine_F32(transform));
}
origin: org.boofcv/demonstrations

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

origin: org.boofcv/demonstrations

@Override
protected void handleInputChange(int source, InputMethod method, int width, int height) {
  super.handleInputChange(source, method, width, height);
  if( inputCopy.getWidth() != width || inputCopy.getHeight() != height ) {
    panelImage.setPreferredSize(new Dimension(width,height));
    distortImage.setModel(distorter); // let it know the transform has changed
  }
  distorter.setEquirectangularShape(width, height);
}
origin: org.boofcv/demonstrations

  private void controlPointsModified() {
    synchronized (pointsUndistorted){
      try {
        // transform needs to go from distorted image to undistorted image
        alg.setSource(pointsDistorted);
        alg.setDestination(pointsUndistorted);
        validTransform = true;
      } catch( RuntimeException e ) {
//                System.out.println("Failed because of "+e.getMessage());
//                System.out.println("   total points "+pointsDistorted.size());
        validTransform = false;
      }
    }
    distortImage.setModel(p2p);
    if( inputMethod == InputMethod.IMAGE ) {
      renderDistorted(null, undistorted);
    }
    gui.repaint();
  }

origin: org.boofcv/demonstrations

  @Override
  public void mouseClicked(MouseEvent e) {
    GeoLL_F32 geo = new GeoLL_F32();
    synchronized (distorter) {
      EquirectangularTools_F32 tools = distorter.getTools();
      double scale = panelImage.scale;
      distorter.compute((int) (e.getX() / scale), (int) (e.getY() / scale));
      tools.equiToLatLonFV(distorter.distX, distorter.distY, geo);
      panelRotate.setOrientation(UtilAngle.radianToDegree(geo.lat), UtilAngle.radianToDegree(geo.lon),0);
      distorter.setDirection(geo.lon, geo.lat, 0);
      distortImage.setModel(distorter); // let it know the transform has changed
      if (inputMethod == InputMethod.IMAGE) {
        renderOutput(inputCopy);
      }
    }
  }
});
origin: org.boofcv/demonstrations

  @Override
  public void mouseClicked(MouseEvent e) {
    GeoLL_F32 geo = new GeoLL_F32();
    synchronized (distorter) {
      EquirectangularTools_F32 tools = distorter.getTools();
      double scale = panelImage.scale;
      distorter.compute((int) (e.getX() / scale), (int) (e.getY() / scale));
      tools.equiToLatLonFV(distorter.distX, distorter.distY, geo);
      panelRotate.setOrientation(UtilAngle.radianToDegree(geo.lat), UtilAngle.radianToDegree(geo.lon),0);
      distorter.setDirection(geo.lon, geo.lat, 0);
      distortImage.setModel(distorter); // let it know the transform has changed
      if (inputMethod == InputMethod.IMAGE) {
        renderOutput(inputCopy);
      }
    }
  }
});
origin: org.boofcv/demonstrations

private void addUndistorted(final String name, final Point2Transform2_F32 model) {
  // Set up image distort
  InterpolatePixel<T> interp = FactoryInterpolation.
      createPixel(0,255,InterpolationType.BILINEAR, BorderType.ZERO, undist.getImageType());
  ImageDistort<T,T> undistorter = FactoryDistort.distort(false, interp, undist.getImageType());
  undistorter.setModel(new PointToPixelTransform_F32(model));
  undistorter.apply(dist,undist);
  final BufferedImage out = ConvertBufferedImage.convertTo(undist,null,true);
  // Add this rectified image
  SwingUtilities.invokeLater(new Runnable() {
    public void run() {
      gui.addItem(new ImagePanel(out), name);
    }});
}
origin: org.boofcv/demonstrations

@Override
public void updatedOrientation(double pitch, double yaw, double roll) {
  synchronized (distorter) {
    ConvertRotation3D_F32.eulerToMatrix(EulerType.ZYX,
        (float)UtilAngle.degreeToRadian(yaw),
        (float)UtilAngle.degreeToRadian(pitch),
        (float)UtilAngle.degreeToRadian(roll),
        distorter.getRotation());
    distortImage.setModel(distorter); // let it know the transform has changed
    if (inputMethod == InputMethod.IMAGE) {
      renderOutput(inputCopy);
    }
  }
}
origin: org.boofcv/demonstrations

@Override
public void updatedOrientation(double pitch, double yaw, double roll) {
  synchronized (distorter) {
    ConvertRotation3D_F32.eulerToMatrix(EulerType.ZYX,
        (float)UtilAngle.degreeToRadian(yaw),
        (float)UtilAngle.degreeToRadian(pitch),
        (float)UtilAngle.degreeToRadian(roll),
        distorter.getRotation());
    distortImage.setModel(distorter); // let it know the transform has changed
    if (inputMethod == InputMethod.IMAGE) {
      renderOutput(inputCopy);
    }
  }
}
origin: org.boofcv/geo

/**
 * Creates an {@link ImageDistort} for rectifying an image given its radial distortion and
 * rectification matrix.
 *
 * @param param Intrinsic parameters.
 * @param rectify Transform for rectifying the image.
 * @param imageType Type of single band image the transform is to be applied to.
 * @return ImageDistort for rectifying the image.
 */
public static <T extends ImageBase> ImageDistort<T,T>
rectifyImage(CameraPinholeRadial param, DenseMatrix64F rectify , BorderType borderType, ImageType<T> imageType)
{
  boolean skip = borderType == BorderType.SKIP;
  if( skip ) {
    borderType = BorderType.EXTENDED;
  }
  InterpolatePixel<T> interp =
      FactoryInterpolation.createPixel(0,255, InterpolationType.BILINEAR,borderType,imageType);
  // only compute the transform once
  ImageDistort<T,T> ret = FactoryDistort.distort(true, interp, imageType);
  ret.setRenderAll(!skip);
  Point2Transform2_F32 transform = transformRectToPixel_F32(param, rectify);
  ret.setModel(new PointToPixelTransform_F32(transform));
  return ret;
}
origin: lessthanoptimal/BoofAndroidDemo

@Override
public void initialize(int imageWidth, int imageHeight, int sensorOrientation) {
  undistorted = imageType.createImage(imageWidth,imageHeight);
  CameraPinholeRadial intrinsic = app.preference.lookup(
      imageWidth,imageHeight);
  if( intrinsic != null ) {
    // define the transform.  Cache the results for quick rendering later on
    CameraPinhole desired = new CameraPinhole();
    desired.set(intrinsic);
    Point2Transform2_F32 fullView = LensDistortionOps.transformChangeModel_F32(AdjustmentType.FULL_VIEW,
        intrinsic,desired,false,null);
    InterpolatePixelS<GrayU8> interp = FactoryInterpolation.
        bilinearPixelS(GrayU8.class, BorderType.ZERO);
    // for some reason not caching is faster on a low end phone.  Maybe it has to do with CPU memory
    // cache misses when looking up a point?
    removeDistortion = FactoryDistort.distort(false,interp,imageType);
    removeDistortion.setModel(new PointToPixelTransform_F32(fullView));
  }
}
origin: org.boofcv/boofcv-swing

public void setCalibration(CameraUniversalOmni fisheyeModel) {
  BoofSwingUtil.checkGuiThread();
  LensDistortionNarrowFOV pinholeDistort = new LensDistortionPinhole(pinholeModel);
  fisheyeDistort = new LensDistortionUniversalOmni(fisheyeModel);
  distorter = new NarrowToWidePtoP_F32(pinholeDistort,fisheyeDistort);
  // Create the image distorter which will render the image
  InterpolatePixel<Planar<GrayF32>> interp = FactoryInterpolation.
      createPixel(0, 255, InterpolationType.BILINEAR, BorderType.ZERO, imageFisheye.getImageType());
  distortImage = FactoryDistort.distort(false,interp,imageFisheye.getImageType());
  // Pass in the transform created above
  distortImage.setModel(new PointToPixelTransform_F32(distorter));
  setPinholeCenter(fisheyeModel.width/2,fisheyeModel.height/2);
  renderPinhole();
}
origin: org.boofcv/boofcv-swing

public void setPinholeCenter( double pixelX , double pixelY ) {
  this.pixelX = pixelX;
  this.pixelY = pixelY;
  Point3D_F32 norm = new Point3D_F32();
  fisheyeDistort.undistortPtoS_F32().compute((float)pixelX, (float)pixelY, norm);
  Rodrigues_F32 rotation = new Rodrigues_F32();
  Vector3D_F32 canonical = new Vector3D_F32(0,0,1);
  rotation.theta = UtilVector3D_F32.acute(new Vector3D_F32(norm),canonical);
  GeometryMath_F32.cross(canonical,norm,rotation.unitAxisRotation);
  rotation.unitAxisRotation.normalize();
  FMatrixRMaj R = ConvertRotation3D_F32.rodriguesToMatrix(rotation,null);
  distorter.setRotationWideToNarrow(R);
  distortImage.setModel(new PointToPixelTransform_F32(distorter));
}
boofcv.alg.distortImageDistortsetModel

Javadoc

Specifies how pixel coordinates are transformed from the destination to source images.

Popular methods of ImageDistort

  • apply
    Applies the transform, but marks pixels in the mask as 1 = inside, 0 = outside. Where inside pixels
  • setRenderAll
    Specifies if the entire output image should be rendered, even if mapping to the source image is outs
  • getModel
    Returns the distortion model.
  • getRenderAll
    Returns the render all flag

Popular in Java

  • Making http requests using okhttp
  • setContentView (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • scheduleAtFixedRate (Timer)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Path (java.nio.file)
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • JFrame (javax.swing)
  • Option (scala)
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now