Package org.jvision.camera.distortion
Class SimpleLensDistortionBrown
java.lang.Object
org.jvision.camera.distortion.SimpleLensDistortionBrown
- All Implemented Interfaces:
LensDistortion,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)
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
-
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 -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new Brown based lens distortion with no distortion.SimpleLensDistortionBrown(double[] coefficients)Create a new distortion representation based on Brown formalization from the givenfloatarray.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).SimpleLensDistortionBrown(float[] coefficients)Create a new distortion representation based on Brown formalization from the givenfloatarray.SimpleLensDistortionBrown(org.jeometry.math.Vector coefficients)Create a new distortion representation based on Brown formalization from the givenvector. -
Method Summary
Modifier and TypeMethodDescriptionorg.jeometry.geom2D.point.Point2Ddistort(org.jeometry.geom2D.point.Point2D undistorted)org.jeometry.geom2D.point.Point2Ddistort(org.jeometry.geom2D.point.Point2D undistorted, org.jeometry.geom2D.point.Point2D distorted)org.jeometry.math.VectorGet the distortion coefficients as thevector(k1, k2, k3, k4, p1, p2, p3, p4) (8 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 [k1, k2, k3, k4, p1, p2, p3, p4] (length 8).double[]getDistortionCoefficientsDouble(double[] coefficients)Get the distortion coefficients as adoublearray by filling the givencoefficients.float[]Get the distortion coefficients as thefloatarray [k1, k2, k3, k4, p1, p2, p3, p4] (length 8).float[]getDistortionCoefficientsFloat(float[] coefficients)Get the distortion coefficients as afloatarray by filling the givencoefficients.intdoublegetK1()doublegetK2()doublegetK3()doublegetK4()doublegetP1()doublegetP2()doublegetP3()doublegetP4()intvoidsetDistortionCoefficients(double[] coefficients)Set the coefficients of the distortion from the givenfloatarray.voidsetDistortionCoefficients(double k1, double k2, double k3, double k4, double p1, double p2, double p3, double p4)voidsetDistortionCoefficients(float[] coefficients)Set the coefficients of the distortion from the givenfloatarray.voidsetDistortionCoefficients(org.jeometry.math.Vector coefficients)Set the coefficients of the distortion from the givenvector.voidsetUndistortIterationMax(int max)org.jeometry.geom2D.point.Point2Dundistort(org.jeometry.geom2D.point.Point2D distorted)org.jeometry.geom2D.point.Point2Dundistort(org.jeometry.geom2D.point.Point2D distorted, org.jeometry.geom2D.point.Point2D undistorted)
-
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 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 coefficientp3- the third tangential distortion coefficientp4- the fourth tangential distortion coefficient
-
SimpleLensDistortionBrown
public SimpleLensDistortionBrown(org.jeometry.math.Vector coefficients)Create a new distortion representation based on Brown formalization from the givenvector. 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 givenfloatarray. 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 givenfloatarray. 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
- Specified by:
getDistortionConventionin interfaceLensDistortion
-
getDistortionComponents
public int getDistortionComponents()- Specified by:
getDistortionComponentsin interfaceLensDistortion
-
distort
public org.jeometry.geom2D.point.Point2D distort(org.jeometry.geom2D.point.Point2D undistorted)- Specified by:
distortin interfaceLensDistortion
-
distort
public org.jeometry.geom2D.point.Point2D distort(org.jeometry.geom2D.point.Point2D undistorted, org.jeometry.geom2D.point.Point2D distorted)- Specified by:
distortin interfaceLensDistortion
-
undistort
public org.jeometry.geom2D.point.Point2D undistort(org.jeometry.geom2D.point.Point2D distorted)- Specified by:
undistortin interfaceLensDistortion
-
undistort
public org.jeometry.geom2D.point.Point2D undistort(org.jeometry.geom2D.point.Point2D distorted, org.jeometry.geom2D.point.Point2D undistorted)- Specified by:
undistortin interfaceLensDistortion
-
getDistortionCoefficients
public org.jeometry.math.Vector getDistortionCoefficients()Get the distortion coefficients as thevector(k1, k2, k3, k4, p1, p2, p3, p4) (8 dimensions).- Specified by:
getDistortionCoefficientsin interfaceLensDistortion- Returns:
- the distortion coefficients
-
getDistortionCoefficients
public 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, p3, p4) (8 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
public void setDistortionCoefficients(org.jeometry.math.Vector coefficients)Set the coefficients of the distortion from the givenvector. 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:
setDistortionCoefficientsin interfaceLensDistortion- Parameters:
coefficients- the distortion coefficients- See Also:
setDistortionCoefficients(float[]),setDistortionCoefficients(double[])
-
getDistortionCoefficientsFloat
public float[] getDistortionCoefficientsFloat()Get the distortion coefficients as thefloatarray [k1, k2, k3, k4, p1, p2, p3, p4] (length 8).- Specified by:
getDistortionCoefficientsFloatin interfaceLensDistortion- Returns:
- the distortion coefficients
-
getDistortionCoefficientsFloat
public float[] getDistortionCoefficientsFloat(float[] coefficients) throws IllegalArgumentExceptionGet the distortion coefficients as afloatarray by filling the givencoefficients. 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:
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
public void setDistortionCoefficients(float[] coefficients)Set the coefficients of the distortion from the givenfloatarray. 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:
setDistortionCoefficientsin interfaceLensDistortion- Parameters:
coefficients- the distortion coefficients
-
getDistortionCoefficientsDouble
public double[] getDistortionCoefficientsDouble()Get the distortion coefficients as adoublearray [k1, k2, k3, k4, p1, p2, p3, p4] (length 8).- Specified by:
getDistortionCoefficientsDoublein interfaceLensDistortion- Returns:
- the distortion coefficients
-
getDistortionCoefficientsDouble
public double[] getDistortionCoefficientsDouble(double[] coefficients) throws IllegalArgumentExceptionGet the distortion coefficients as adoublearray by filling the givencoefficients. 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:
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
public void setDistortionCoefficients(double[] coefficients)Set the coefficients of the distortion from the givenfloatarray. 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:
setDistortionCoefficientsin interfaceLensDistortion- Parameters:
coefficients- the distortion coefficients
-
getK1
public double getK1()- Specified by:
getK1in interfaceLensDistortionBrown
-
getK2
public double getK2()- Specified by:
getK2in interfaceLensDistortionBrown
-
getK3
public double getK3()- Specified by:
getK3in interfaceLensDistortionBrown
-
getK4
public double getK4()- Specified by:
getK4in interfaceLensDistortionBrown
-
getP1
public double getP1()- Specified by:
getP1in interfaceLensDistortionBrown
-
getP2
public double getP2()- Specified by:
getP2in interfaceLensDistortionBrown
-
getP3
public double getP3()- Specified by:
getP3in interfaceLensDistortionBrown
-
getP4
public double getP4()- Specified by:
getP4in interfaceLensDistortionBrown
-
getUndistortIterationMax
public int getUndistortIterationMax()- Specified by:
getUndistortIterationMaxin interfaceLensDistortionBrown
-
setUndistortIterationMax
public void setUndistortIterationMax(int max)- Specified by:
setUndistortIterationMaxin interfaceLensDistortionBrown
-
setDistortionCoefficients
public void setDistortionCoefficients(double k1, double k2, double k3, double k4, double p1, double p2, double p3, double p4)- Specified by:
setDistortionCoefficientsin interfaceLensDistortionBrown
-