Interface LensDistortionMetashape

All Superinterfaces:
LensDistortion

public interface LensDistortionMetashape extends LensDistortion
An interface that class describes the lens distortion within the Agisoft Metashape(c) convention.
The distortion is used to compute distorted / undistorted points for a given camera. Let (X, Y, Z) be a 3D point expressed within the camera referential.

A new point (u, v) that integrate distortion (a distorted point) can be obtained a follows:
 
x=X / Z
y=Y / Z
 
x'=x(1 + k1r2 + k2r4 + k3r6 + k4r8)+(P1(r2+2x2) + 2P2xy)
 
y'=x(1 + k1r2 + k2r4 + k3r6 + k4r8)+(P2(r2+2y2) + 2P1xy)

with:
  • (x', y') is a point within camera referential that is affected by the distortion.
  • r2 = x2 + y2.
  • k1, k2, k3, k4 are the radial distortion coefficients.
  • p1, p2 are the tangential distortion coefficients.
We got then:
 
u = w × 0.5 + cx + x'f + x'B1 + y'B2
v = h × 0.5 + cy + y'f

with:
  • (u, v) is a point within the image referential that is affected by the distortion expressed in pixels (px).
  • w is the digital image width in pixels (px).
  • h is the digital image height in pixels (px).
  • (cx, cy) is the principal point offset expressed in pixels (px).
  • f is the camera focal length in pixels (px).
  • B1 is the affinity coefficient.
  • B2 is the non-orthogonality (skew) coefficient.
Since:
1.0.0
Version:
"1.0.0" b202104211400L
Author:
Julien Seinturier - JOrigin - contact@jorigin.org - https://github.com/jorigin/jvision
  • Method Details

    • getDistortionCoefficients

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

      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) (6 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

      void setDistortionCoefficients(org.jeometry.math.Vector coefficients) throws IllegalArgumentException
      Set the distortion coefficients from the given vector. Accepted vectors are:
      • (k1, k2, k3, k4, p1, p2) (6 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
      Throws:
      IllegalArgumentException - if the input vector does match the distortion implementation requirement
    • getDistortionCoefficientsFloat

      float[] getDistortionCoefficientsFloat()
      Get the distortion coefficients as a float array. Possible output vectors are:
      • [k1, k2, k3, k4, p1, p2] (6 dimensions)
      • [k1, k2, k3, p1, p2] (5 dimensions)
      • [k1, k2, k3] (3 dimensions)
      Specified by:
      getDistortionCoefficientsFloat in interface LensDistortion
      Returns:
      the distortion coefficients
    • getDistortionCoefficientsFloat

      float[] getDistortionCoefficientsFloat(float[] coefficients) throws IllegalArgumentException
      Get the distortion coefficients as a float array by filling the given coefficients. Possible output arrays are:
      • [k1, k2, k3, k4, p1, p2] (length 6)
      • [k1, k2, k3, p1, p2] (length 5)
      • [k1, k2, k3] (length 3)
      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

      void setDistortionCoefficients(float[] coefficients) throws IllegalArgumentException
      Set the distortion coefficients from the given float array. Accepted arrays are:
      • [k1, k2, k3, k4, p1, p2] (length 6)
      • [k1, k2, k3, p1, p2] (length 5)
      • [k1, k2, k3] (length 3)
      • null or empty array for no distortion
      Specified by:
      setDistortionCoefficients in interface LensDistortion
      Parameters:
      coefficients - the distortion coefficients
      Throws:
      IllegalArgumentException - if the input array does match the distortion implementation requirement
    • getDistortionCoefficientsDouble

      double[] getDistortionCoefficientsDouble()
      Get the distortion coefficients as a double array. Possible output arrays are:
      • [k1, k2, k3, k4, p1, p2] (length 6)
      • [k1, k2, k3, p1, p2] (length 5)
      • [k1, k2, k3] (length 3)
      Specified by:
      getDistortionCoefficientsDouble in interface LensDistortion
      Returns:
      the distortion coefficients
    • getDistortionCoefficientsDouble

      double[] getDistortionCoefficientsDouble(double[] coefficients) throws IllegalArgumentException
      Get the distortion coefficients as a double array by filling the given coefficients. Possible output arrays are:
      • [k1, k2, k3, k4, p1, p2] (length 6)
      • [k1, k2, k3, p1, p2] (length 5)
      • [k1, k2, k3] (length 3)
      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

      void setDistortionCoefficients(double[] coefficients) throws IllegalArgumentException
      Set the distortion coefficients from the given double array. Accepted arrays are:
      • [k1, k2, k3, k4, p1, p2] (length 6)
      • [k1, k2, k3, p1, p2] (length 5)
      • [k1, k2, k3] (length 3)
      • null or empty array for no distortion
      Specified by:
      setDistortionCoefficients in interface LensDistortion
      Parameters:
      coefficients - the distortion coefficients
      Throws:
      IllegalArgumentException - if the input array does match the distortion implementation requirement
    • getK1

      double getK1()
      Get the first radial distortion coefficient k1.
      Returns:
      the first radial distortion coefficient k1
      See Also:
      setK1(double), getK2(), getK3(), getK4()
    • setK1

      void setK1(double k1)
      Set the first radial distortion coefficient k1.
      Parameters:
      k1 - the first radial distortion coefficient k1
      See Also:
      getK1(), setK2(double), setK3(double), setK4(double)
    • getK2

      double getK2()
      Get the second radial distortion coefficient k2.
      Returns:
      the second radial distortion coefficient k2
      See Also:
      setK2(double), getK1(), getK3(), getK4()
    • setK2

      void setK2(double k2)
      Set the second radial distortion coefficient k2.
      Parameters:
      k2 - the second radial distortion coefficient k2
      See Also:
      getK2(), setK1(double), setK3(double), setK4(double)
    • getK3

      double getK3()
      Get the third radial distortion coefficient k3.
      Returns:
      the third radial distortion coefficient k3
      See Also:
      setK3(double), getK1(), getK2(), getK4()
    • setK3

      void setK3(double k3)
      Set the third radial distortion coefficient k3.
      Parameters:
      k3 - the third radial distortion coefficient k3
      See Also:
      getK3(), setK1(double), setK2(double), setK4(double)
    • getK4

      double getK4()
      Get the fourth radial distortion coefficient k4.
      Returns:
      the fourth radial distortion coefficient k4
      See Also:
      setK4(double), getK1(), getK2(), getK3()
    • setK4

      void setK4(double k4)
      Set the fourth radial distortion coefficient k4.
      Parameters:
      k4 - the third radial distortion coefficient k4
      See Also:
      getK4(), setK1(double), setK2(double), setK3(double)
    • getP1

      double getP1()
      Get the first tangential distortion coefficient p1.
      Returns:
      the first tangential distortion coefficient p1
      See Also:
      setP1(double), getP2()
    • setP1

      void setP1(double p1)
      Set the first tangential distortion coefficient p1.
      Parameters:
      p1 - the first tangential distortion coefficient p1
      See Also:
      getP1(), setP2(double)
    • getP2

      double getP2()
      Get the second tangential distortion coefficient p2.
      Returns:
      the second tangential distortion coefficient p2
      See Also:
      setP2(double), getP1()
    • setP2

      void setP2(double p2)
      Set the second tangential distortion coefficient p2.
      Parameters:
      p2 - the second tangential distortion coefficient p2
      See Also:
      getP2(), setP1(double)
    • setDistortionCoefficients

      void setDistortionCoefficients(double k1, double k2, double k3, double k4, double p1, double p2)
      Set the distortion coefficients.
      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