Class SimpleLensDistortionBrown

java.lang.Object
org.jvision.camera.distortion.SimpleLensDistortionBrown
All Implemented Interfaces:
LensDistortion, LensDistortionBrown

public class SimpleLensDistortionBrown extends Object implements LensDistortionBrown
A class dedicated to the handling of lens distortion within the Brown model. A complete description of the model can be found in Decentering distortion of lenses

The distortion is used to compute distorted / undistorted points for a given camera. Let (x, y) be the projection of a 3D point onto an image. A new point (x', y') that integrate distortion (a distorted point) can be obtained a follows:

r = sqrt(x2 + y2)
x' = x(1 + K1r2 + K2r4 + K3r6 + K4r8) + (P2(r2+2x2) + 2P1xy)(1 + P3r2 + P4r4)
y' = y(1 + K1r2 + K2r4 + K3r6 + K4r8) + (P1(r2+2y2) + 2P2xy)(1 + P3r2 + P4r4)
Since:
1.0.0
Version:
"1.0.0" b202104211400L
Author:
Julien Seinturier - JOrigin - contact@jorigin.org - https://github.com/jorigin/jvision
  • Constructor Details

    • SimpleLensDistortionBrown

      public SimpleLensDistortionBrown()
      Create a new Brown based lens distortion with no distortion.
    • SimpleLensDistortionBrown

      public SimpleLensDistortionBrown(double k1, double k2, double k3, double k4, double p1, double p2, double p3, double p4)
      Create a new distortion representation based on Brown formalization with radial coefficients (k1, k2, k3, k4) and tangential coefficients (p1, p2, p3, p4).
      Parameters:
      k1 - the first radial distortion coefficient
      k2 - the second radial distortion coefficient
      k3 - the third radial distortion coefficient
      k4 - the fourth radial distortion coefficient
      p1 - the first tangential distortion coefficient
      p2 - the second tangential distortion coefficient
      p3 - the third tangential distortion coefficient
      p4 - the fourth tangential distortion coefficient
    • SimpleLensDistortionBrown

      public SimpleLensDistortionBrown(org.jeometry.math.Vector coefficients)
      Create a new distortion representation based on Brown formalization from the given vector. Possible vector values are:
      • (k1, k2, k3, k4, p1, p2, p3, p4) (8 dimensions)
      • (k1, k2, k3, p1, p2) (5 dimensions)
      • (k1, k2, k3) (3 dimensions)
      • null or empty vector for no distortion
      Parameters:
      coefficients - the distortion coefficients
    • SimpleLensDistortionBrown

      public SimpleLensDistortionBrown(float[] coefficients)
      Create a new distortion representation based on Brown formalization from the given float array. Possible vector values are:
      • [k1, k2, k3, k4, p1, p2, p3, p4] (8 values)
      • [k1, k2, k3, p1, p2] (5 values)
      • [k1, k2, k3] (3 values)
      • null or empty array for no distortion
      Parameters:
      coefficients - the distortion coefficients
    • SimpleLensDistortionBrown

      public SimpleLensDistortionBrown(double[] coefficients)
      Create a new distortion representation based on Brown formalization from the given float array. Possible vector values are:
      • [k1, k2, k3, k4, p1, p2, p3, p4] (8 values)
      • [k1, k2, k3, p1, p2] (5 values)
      • [k1, k2, k3] (3 values)
      • null or empty array for no distortion
      Parameters:
      coefficients - the distortion coefficients
  • Method Details

    • getDistortionConvention

      public String getDistortionConvention()
      Specified by:
      getDistortionConvention in interface LensDistortion
    • getDistortionComponents

      public int getDistortionComponents()
      Specified by:
      getDistortionComponents in interface LensDistortion
    • distort

      public org.jeometry.geom2D.point.Point2D distort(org.jeometry.geom2D.point.Point2D undistorted)
      Specified by:
      distort in interface LensDistortion
    • distort

      public org.jeometry.geom2D.point.Point2D distort(org.jeometry.geom2D.point.Point2D undistorted, org.jeometry.geom2D.point.Point2D distorted)
      Specified by:
      distort in interface LensDistortion
    • undistort

      public org.jeometry.geom2D.point.Point2D undistort(org.jeometry.geom2D.point.Point2D distorted)
      Specified by:
      undistort in interface LensDistortion
    • undistort

      public org.jeometry.geom2D.point.Point2D undistort(org.jeometry.geom2D.point.Point2D distorted, org.jeometry.geom2D.point.Point2D undistorted)
      Specified by:
      undistort in interface LensDistortion
    • getDistortionCoefficients

      public org.jeometry.math.Vector getDistortionCoefficients()
      Get the distortion coefficients as the vector (k1, k2, k3, k4, p1, p2, p3, p4) (8 dimensions).
      Specified by:
      getDistortionCoefficients in interface LensDistortion
      Returns:
      the distortion coefficients
    • getDistortionCoefficients

      public org.jeometry.math.Vector getDistortionCoefficients(org.jeometry.math.Vector coefficients) throws IllegalArgumentException
      Get the distortion coefficients as a vector by filling the given coefficients. Possible output vectors are:
      • (k1, k2, k3, k4, p1, p2, p3, p4) (8 dimensions)
      • (k1, k2, k3, p1, p2) (5 dimensions)
      • (k1, k2, k3) (3 dimensions)
      Specified by:
      getDistortionCoefficients in interface LensDistortion
      Parameters:
      coefficients - the output vector that has to store distortion coefficients
      Returns:
      a reference on the given vector, for chaining purposes
      Throws:
      IllegalArgumentException - if the given vector does match the distortion implementation requirement
    • setDistortionCoefficients

      public void setDistortionCoefficients(org.jeometry.math.Vector coefficients)
      Set the coefficients of the distortion from the given vector. Possible vector values are:
      • (k1, k2, k3, k4, p1, p2, p3, p4) (8 dimensions)
      • (k1, k2, k3, p1, p2) (5 dimensions)
      • (k1, k2, k3) (3 dimensions)
      • null or empty vector for no distortion
      Specified by:
      setDistortionCoefficients in interface LensDistortion
      Parameters:
      coefficients - the distortion coefficients
      See Also:
      setDistortionCoefficients(float[]), setDistortionCoefficients(double[])
    • getDistortionCoefficientsFloat

      public float[] getDistortionCoefficientsFloat()
      Get the distortion coefficients as the float array [k1, k2, k3, k4, p1, p2, p3, p4] (length 8).
      Specified by:
      getDistortionCoefficientsFloat in interface LensDistortion
      Returns:
      the distortion coefficients
    • getDistortionCoefficientsFloat

      public float[] getDistortionCoefficientsFloat(float[] coefficients) throws IllegalArgumentException
      Get the distortion coefficients as a float array by filling the given coefficients. Possible vector values are:
      • [k1, k2, k3, k4, p1, p2, p3, p4] (8 values)
      • [k1, k2, k3, p1, p2] (5 values)
      • [k1, k2, k3] (3 values)
      Specified by:
      getDistortionCoefficientsFloat in interface LensDistortion
      Parameters:
      coefficients - the output array that has to store distortion coefficients
      Returns:
      a reference on the given array, for chaining purposes
      Throws:
      IllegalArgumentException - if the given array does match the distortion implementation requirement
    • setDistortionCoefficients

      public void setDistortionCoefficients(float[] coefficients)
      Set the coefficients of the distortion from the given float array. Possible arrays are:
      • [k1, k2, k3, k4, p1, p2, p3, p4] (8 values)
      • [k1, k2, k3, p1, p2] (5 values)
      • [k1, k2, k3] (3 values)
      • null or empty array for no distortion
      Specified by:
      setDistortionCoefficients in interface LensDistortion
      Parameters:
      coefficients - the distortion coefficients
    • getDistortionCoefficientsDouble

      public double[] getDistortionCoefficientsDouble()
      Get the distortion coefficients as a double array [k1, k2, k3, k4, p1, p2, p3, p4] (length 8).
      Specified by:
      getDistortionCoefficientsDouble in interface LensDistortion
      Returns:
      the distortion coefficients
    • getDistortionCoefficientsDouble

      public double[] getDistortionCoefficientsDouble(double[] coefficients) throws IllegalArgumentException
      Get the distortion coefficients as a double array by filling the given coefficients. Possible vector values are:
      • [k1, k2, k3, k4, p1, p2, p3, p4] (8 values)
      • [k1, k2, k3, p1, p2] (5 values)
      • [k1, k2, k3] (3 values)
      Specified by:
      getDistortionCoefficientsDouble in interface LensDistortion
      Parameters:
      coefficients - the output array that has to store distortion coefficients
      Returns:
      a reference on the given array, for chaining purposes
      Throws:
      IllegalArgumentException - if the given array does match the distortion implementation requirement
    • setDistortionCoefficients

      public void setDistortionCoefficients(double[] coefficients)
      Set the coefficients of the distortion from the given float array. Possible arrays are:
      • [k1, k2, k3, k4, p1, p2, p3, p4] (8 values)
      • [k1, k2, k3, p1, p2] (5 values)
      • [k1, k2, k3] (3 values)
      • null or empty vector for no distortion
      Specified by:
      setDistortionCoefficients in interface LensDistortion
      Parameters:
      coefficients - the distortion coefficients
    • getK1

      public double getK1()
      Specified by:
      getK1 in interface LensDistortionBrown
    • getK2

      public double getK2()
      Specified by:
      getK2 in interface LensDistortionBrown
    • getK3

      public double getK3()
      Specified by:
      getK3 in interface LensDistortionBrown
    • getK4

      public double getK4()
      Specified by:
      getK4 in interface LensDistortionBrown
    • getP1

      public double getP1()
      Specified by:
      getP1 in interface LensDistortionBrown
    • getP2

      public double getP2()
      Specified by:
      getP2 in interface LensDistortionBrown
    • getP3

      public double getP3()
      Specified by:
      getP3 in interface LensDistortionBrown
    • getP4

      public double getP4()
      Specified by:
      getP4 in interface LensDistortionBrown
    • getUndistortIterationMax

      public int getUndistortIterationMax()
      Specified by:
      getUndistortIterationMax in interface LensDistortionBrown
    • setUndistortIterationMax

      public void setUndistortIterationMax(int max)
      Specified by:
      setUndistortIterationMax in interface LensDistortionBrown
    • setDistortionCoefficients

      public void setDistortionCoefficients(double k1, double k2, double k3, double k4, double p1, double p2, double p3, double p4)
      Specified by:
      setDistortionCoefficients in interface LensDistortionBrown