Package org.jvision.camera.distortion
Interface LensDistortionMetashape
- All Superinterfaces:
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:
with:
with:
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.
| 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
-
Field Summary
Fields inherited from interface org.jvision.camera.distortion.LensDistortion
TYPE_NO_DISTORTION, TYPE_PRISM, TYPE_RADIAL, TYPE_RADIAL_RATIONAL, TYPE_RADIAL_SIMPLE, TYPE_TANGENTIAL, TYPE_TILT -
Method Summary
Modifier and TypeMethodDescriptionorg.jeometry.math.VectorGet the distortion parameters as thevector(k1, k2, k3, k4, p1, p2) (6 dimensions).org.jeometry.math.VectorgetDistortionCoefficients(org.jeometry.math.Vector coefficients)Get the distortion coefficients as avectorby filling the givencoefficients.double[]Get the distortion coefficients as adoublearray.double[]getDistortionCoefficientsDouble(double[] coefficients)Get the distortion coefficients as adoublearray by filling the givencoefficients.float[]Get the distortion coefficients as afloatarray.float[]getDistortionCoefficientsFloat(float[] coefficients)Get the distortion coefficients as afloatarray by filling the givencoefficients.doublegetK1()Get the first radial distortion coefficient k1.doublegetK2()Get the second radial distortion coefficient k2.doublegetK3()Get the third radial distortion coefficient k3.doublegetK4()Get the fourth radial distortion coefficient k4.doublegetP1()Get the first tangential distortion coefficient p1.doublegetP2()Get the second tangential distortion coefficient p2.voidsetDistortionCoefficients(double[] coefficients)Set the distortion coefficients from the givendoublearray.voidsetDistortionCoefficients(double k1, double k2, double k3, double k4, double p1, double p2)Set the distortion coefficients.voidsetDistortionCoefficients(float[] coefficients)Set the distortion coefficients from the givenfloatarray.voidsetDistortionCoefficients(org.jeometry.math.Vector coefficients)Set the distortion coefficients from the givenvector.voidsetK1(double k1)Set the first radial distortion coefficient k1.voidsetK2(double k2)Set the second radial distortion coefficient k2.voidsetK3(double k3)Set the third radial distortion coefficient k3.voidsetK4(double k4)Set the fourth radial distortion coefficient k4.voidsetP1(double p1)Set the first tangential distortion coefficient p1.voidsetP2(double p2)Set the second tangential distortion coefficient p2.Methods inherited from interface org.jvision.camera.distortion.LensDistortion
distort, distort, getDistortionComponents, getDistortionConvention, undistort, undistort
-
Method Details
-
getDistortionCoefficients
org.jeometry.math.Vector getDistortionCoefficients()Get the distortion parameters as thevector(k1, k2, k3, k4, p1, p2) (6 dimensions).- Specified by:
getDistortionCoefficientsin interfaceLensDistortion- Returns:
- the distortion coefficients
-
getDistortionCoefficients
org.jeometry.math.Vector getDistortionCoefficients(org.jeometry.math.Vector coefficients) throws IllegalArgumentExceptionGet the distortion coefficients as avectorby filling the givencoefficients. 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:
getDistortionCoefficientsin interfaceLensDistortion- 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 IllegalArgumentExceptionSet the distortion coefficients from the givenvector. 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:
setDistortionCoefficientsin interfaceLensDistortion- 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 afloatarray. 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:
getDistortionCoefficientsFloatin interfaceLensDistortion- Returns:
- the distortion coefficients
-
getDistortionCoefficientsFloat
Get the distortion coefficients as afloatarray by filling the givencoefficients. 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:
getDistortionCoefficientsFloatin interfaceLensDistortion- 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
Set the distortion coefficients from the givenfloatarray. 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:
setDistortionCoefficientsin interfaceLensDistortion- 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 adoublearray. 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:
getDistortionCoefficientsDoublein interfaceLensDistortion- Returns:
- the distortion coefficients
-
getDistortionCoefficientsDouble
Get the distortion coefficients as adoublearray by filling the givencoefficients. 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:
getDistortionCoefficientsDoublein interfaceLensDistortion- 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
Set the distortion coefficients from the givendoublearray. 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:
setDistortionCoefficientsin interfaceLensDistortion- 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 coefficientk2- the second radial distortion coefficientk3- the third radial distortion coefficientk4- the fourth radial distortion coefficientp1- the first tangential distortion coefficientp2- the second tangential distortion coefficient
-