Package org.jvision.camera.distortion
Interface LensDistortionOpenCV
- All Superinterfaces:
LensDistortion
An interface that describes the lens distortion within the OpenCV convention.
A complete description of the convention can be found in Camera calibration With OpenCV
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:
and
with:
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:
| 1 + k1r2 + k2r4 + k3r6 | ||||||||||||
| x'' | = | x' | × | + | 2p1x'y' | + | p2(r2+2x'2) | + | s1r2 | + | s2r4 | |
| 1 + k4r2 + k5r4 + k6r6 |
and
| 1 + k1r2 + k2r4 + k3r6 | ||||||||||||
| y'' | = | y' | × | + | p1(r2+2y'2) | + | 2p2x'y' | + | s3r2 | + | s4r4 | |
| 1 + k4r2 + k5r4 + k6r6 |
- (x', y') is a 3D point within camera referential that is not affected by the distortion.
- (x'', y'') is a point within camera referential that is affected by the distortion.
- r2 = x'2 + y'2.
- k1, ..., k6 are the radial distortion coefficients.
- p1, p2 are the tangential distortion coefficients.
- s1, s2, s3 and s4 are the thin prism distortion coefficients.
- 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.geom2D.point.Point2Ddistort(org.jeometry.geom2D.point.Point2D undistorted)Distort the given point (x', y') expressed wit focal normalized coordinates such as:
x - cx y - cy (x', y')=( , ) fx fy where:
(x, y) are the coordinates of the point on the undistorted image in pixels (px) (cx, cy) are the coordinates of the projection center on the image in pixels (px) fx, fy are respectively the focal lengths along X and Y axis in pixels (px) The distorted point (x'', y'') is such that:
1 + k1r2 + k2r4 + k3r6 x''=x'×+2p1x'y'+p2(r2+2x'2)+s1r2+s2r4 1 + k4r2 + k5r4 + k6r6
and
1 + k1r2 + k2r4 + k3r6 y''=y'×+p1(r2+2y'2)+2p2x'y'+s3r2+s4r4 1 + k4r2 + k5r4 + k6r6 with:
(x', y') is the undistorted point expressed within focal normalized coordinates.org.jeometry.geom2D.point.Point2Ddistort(org.jeometry.geom2D.point.Point2D undistorted, org.jeometry.geom2D.point.Point2D distorted)Distort theinputpoint and store the result withinoutputpoint.org.jeometry.math.VectorGet the distortion parameters as thevector(k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4, τx, τy) (14 dimensions).org.jeometry.math.VectorgetDistortionCoefficients(org.jeometry.math.Vector coefficients)Get the distortion parameters as avectorby filling the givenparameters.double[]Get the distortion coefficients as adoublearray [k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4, τx, τy] (length 14).double[]getDistortionCoefficientsDouble(double[] coefficients)Get the distortion parameters as adoublearray by filling the givencoefficients.float[]Get the distortion coefficients as afloatarray.float[]getDistortionCoefficientsFloat(float[] coefficients)Get the distortion parameters 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.doublegetK5()Get the fifth radial distortion coefficient K5.doublegetK6()Get the sixth radial distortion coefficient K6.doublegetP1()Get the first tangential distortion coefficient P1.doublegetP2()Get the second tangential distortion coefficient P2.doublegetS1()Get the first thin prism distortion coefficient S1.doublegetS2()Get the second thin prism distortion coefficient S2.doublegetS3()Get the third thin prism distortion coefficient S3.doublegetS4()Get the fourth thin prism distortion coefficient S4.doublegetTx()Get the x axis tilt angular coefficient Tx.doublegetTy()Get the y axis tilt angular coefficient Ty.voidsetDistortionCoefficients(double[] coefficients)Set the distortion coefficients from the givendoublearray.voidsetDistortionCoefficients(double k1, double k2, double k3, double p1, double p2)Set the radial and tangential distortion coefficients.voidsetDistortionCoefficients(double k1, double k2, double k3, double k4, double k5, double k6, double p1, double p2)Set the radial and tangential distortion coefficients.voidsetDistortionCoefficients(double k1, double k2, double k3, double k4, double k5, double k6, double p1, double p2, double s1, double s2, double s3, double s4)Set the radial, tangential and thin prism distortion coefficients.voidsetDistortionCoefficients(double k1, double k2, double k3, double k4, double k5, double k6, double p1, double p2, double s1, double s2, double s3, double s4, double tx, double ty)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.voidsetK5(double k5)Set the fifth radial distortion coefficient K5.voidsetK6(double k6)Set the sixth radial distortion coefficient K6.voidsetP1(double p1)Set the first tangential distortion coefficient P1.voidsetP2(double p2)Set the second tangential distortion coefficient P2.voidsetS1(double s1)Set the first thin prism distortion coefficient S1.voidsetS2(double s2)Set the second thin prism distortion coefficient S2.voidsetS3(double s3)Set the third thin prism distortion coefficient S3.voidsetS4(double s4)Set the fourth thin prism distortion coefficient S4.voidsetTx(double tx)Set the x axis tilt angular coefficient Tx.voidsetTy(double ty)Set the y axis tilt angular coefficient Ty.org.jeometry.geom2D.point.Point2Dundistort(org.jeometry.geom2D.point.Point2D distorted)Undistort the given point.org.jeometry.geom2D.point.Point2Dundistort(org.jeometry.geom2D.point.Point2D distorted, org.jeometry.geom2D.point.Point2D undistorted)Undistort theinputpoint and store the result withinoutputpoint.Methods inherited from interface org.jvision.camera.distortion.LensDistortion
getDistortionComponents, getDistortionConvention
-
Method Details
-
distort
org.jeometry.geom2D.point.Point2D distort(org.jeometry.geom2D.point.Point2D undistorted)Distort the given point (x', y') expressed wit focal normalized coordinates such as:
where:x - cx y - cy (x', y') = (
,
) fx fy
- (x, y) are the coordinates of the point on the undistorted image in pixels (px)
- (cx, cy) are the coordinates of the projection center on the image in pixels (px)
- fx, fy are respectively the focal lengths along X and Y axis in pixels (px)
1 + k1r2 + k2r4 + k3r6 x'' = x' × + 2p1x'y' + p2(r2+2x'2) + s1r2 + s2r4 1 + k4r2 + k5r4 + k6r6
and
with:1 + k1r2 + k2r4 + k3r6 y'' = y' × + p1(r2+2y'2) + 2p2x'y' + s3r2 + s4r4 1 + k4r2 + k5r4 + k6r6
- (x', y') is the undistorted point expressed within focal normalized coordinates.
- (x'', y'') is a point expressed within focal normalized coordinates that is affected by the distortion.
- r2 = x'2 + y'2.
- k1, ..., k6 are the radial distortion coefficients.
- p1, p2 are the tangential distortion coefficients.
- s1, s2, s3 and s4 are the thin prism distortion coefficients.
undistortedpoint isnull, coordinates of the result are set toDouble.NaN.- Specified by:
distortin interfaceLensDistortion- Parameters:
undistorted- the input point within focal normalized coordinates.- Returns:
- the distorted point.
- See Also:
undistort(Point2D)
-
distort
org.jeometry.geom2D.point.Point2D distort(org.jeometry.geom2D.point.Point2D undistorted, org.jeometry.geom2D.point.Point2D distorted)Distort theinputpoint and store the result withinoutputpoint. The point have to be expressed within camera coordinates. If the input isnull, coordinates of the result are set toDouble.NaN.- Specified by:
distortin interfaceLensDistortion- Parameters:
undistorted- the input point within camera coordinates.distorted- the output point within camera coordinates.- Returns:
- the distorted point (same reference as
outputif its notnull). - See Also:
undistort(Point2D, Point2D)
-
undistort
org.jeometry.geom2D.point.Point2D undistort(org.jeometry.geom2D.point.Point2D distorted)Undistort the given point. The point have to be expressed within image coordinates. If the input isnull, coordinates of the result are set toDouble.NaN.- Specified by:
undistortin interfaceLensDistortion- Parameters:
distorted- the input point within image coordinates.- Returns:
- the undistorted point.
- See Also:
distort(Point2D)
-
undistort
org.jeometry.geom2D.point.Point2D undistort(org.jeometry.geom2D.point.Point2D distorted, org.jeometry.geom2D.point.Point2D undistorted)Undistort theinputpoint and store the result withinoutputpoint. The point have to be expressed within image coordinates. If the input isnull, coordinates of the result are set toDouble.NaN.- Specified by:
undistortin interfaceLensDistortion- Parameters:
distorted- the input point within image coordinates.undistorted- the output point within camera coordinates.- Returns:
- the undistorted point (same reference as
outputif its notnull). - See Also:
distort(Point2D, Point2D)
-
getDistortionCoefficients
org.jeometry.math.Vector getDistortionCoefficients()Get the distortion parameters as thevector(k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4, τx, τy) (14 dimensions).- Specified by:
getDistortionCoefficientsin interfaceLensDistortion- Returns:
- the distortion parameters
-
getDistortionCoefficients
org.jeometry.math.Vector getDistortionCoefficients(org.jeometry.math.Vector coefficients) throws IllegalArgumentExceptionGet the distortion parameters as avectorby filling the givenparameters. Possible output vectors are:- (k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4, τx, τy) (14 dimensions)
- (k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4) (12 dimensions)
- (k1, k2 , p1, p2, k3, k4, k5, k6) (8 dimensions)
- (k1, k2 , p1, p2, k3) (5 dimensions)
- (k1, k2 , p1, p2) (4 dimensions)
- Specified by:
getDistortionCoefficientsin interfaceLensDistortion- Parameters:
coefficients- the output vector that has to store distortion parameters- 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. Possible vectors are:- (k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4, τx, τy) (14 dimensions)
- (k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4) (12 dimensions)
- (k1, k2 , p1, p2, k3, k4, k5, k6) (8 dimensions)
- (k1, k2 , p1, p2, k3) (5 dimensions)
- (k1, k2 , p1, p2) (4 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 arrays are:- [k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4, τx, τy] (length 14)
- [k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4] (length 12)
- [k1, k2 , p1, p2, k3, k4, k5, k6] (length 8)
- [k1, k2 , p1, p2, k3] (length 5)
- [k1, k2 , p1, p2] (length 4)
- Specified by:
getDistortionCoefficientsFloatin interfaceLensDistortion- Returns:
- the distortion coefficients
-
getDistortionCoefficientsFloat
Get the distortion parameters as afloatarray by filling the givencoefficients. Possible output arrays are:- [k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4, τx, τy] (length 14)
- [k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4] (length 12)
- [k1, k2 , p1, p2, k3, k4, k5, k6] (length 8)
- [k1, k2 , p1, p2, k3] (length 5)
- [k1, k2 , p1, p2] (length 4)
- 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. Possible arrays are:- [k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4, τx, τy] (length 14)
- [k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4] (length 12)
- [k1, k2 , p1, p2, k3, k4, k5, k6] (length 8)
- [k1, k2 , p1, p2, k3] (length 5)
- [k1, k2 , p1, p2] (length 4)
- 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 [k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4, τx, τy] (length 14).- Specified by:
getDistortionCoefficientsDoublein interfaceLensDistortion- Returns:
- the distortion coefficients
-
getDistortionCoefficientsDouble
Get the distortion parameters as adoublearray by filling the givencoefficients. Possible output arrays are:- [k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4, τx, τy] (length 14)
- [k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4] (length 12)
- [k1, k2 , p1, p2, k3, k4, k5, k6] (length 8)
- [k1, k2 , p1, p2, k3] (length 5)
- [k1, k2 , p1, p2] (length 4)
- 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. Possible arrays are:- [k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4, τx, τy] (length 14)
- [k1, k2 , p1, p2, k3, k4, k5, k6, s1, s2, s3, s4] (length 12)
- [k1, k2 , p1, p2, k3, k4, k5, k6] (length 8)
- [k1, k2 , p1, p2, k3] (length 5)
- [k1, k2 , p1, p2] (length 4)
- 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()
-
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)
-
getK2
double getK2()Get the second radial distortion coefficient K2.- Returns:
- the second radial distortion coefficient K2.
- See Also:
setK2(double),getK1(),getK3()
-
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)
-
getK3
double getK3()Get the third radial distortion coefficient K3.- Returns:
- the third radial distortion coefficient K3.
- See Also:
setK3(double),getK1(),getK2()
-
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)
-
getK4
double getK4()Get the fourth radial distortion coefficient K4.- Returns:
- the fourth radial distortion coefficient K4.
- See Also:
setK4(double),getK5(),getK6()
-
setK4
void setK4(double k4)Set the fourth radial distortion coefficient K4.- Parameters:
k4- the fourth radial distortion coefficient K4.- See Also:
getK4(),setK5(double),setK6(double)
-
getK5
double getK5()Get the fifth radial distortion coefficient K5.- Returns:
- the fourth radial distortion coefficient K5.
- See Also:
setK5(double),getK4(),getK6()
-
setK5
void setK5(double k5)Set the fifth radial distortion coefficient K5.- Parameters:
k5- the fourth radial distortion coefficient K5.- See Also:
getK5(),setK4(double),setK6(double)
-
getK6
double getK6()Get the sixth radial distortion coefficient K6.- Returns:
- the fourth radial distortion coefficient K6.
- See Also:
setK6(double),getK4(),getK5()
-
setK6
void setK6(double k6)Set the sixth radial distortion coefficient K6.- Parameters:
k6- the fourth radial distortion coefficient K6.- See Also:
getK6(),setK4(double),setK5(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)
-
getS1
double getS1()Get the first thin prism distortion coefficient S1.- Returns:
- the first thin prism distortion coefficient S1.
- See Also:
setS1(double),getS2(),getS3(),getS4()
-
setS1
void setS1(double s1)Set the first thin prism distortion coefficient S1.- Parameters:
s1- the first thin prism distortion coefficient S1.- See Also:
getS1(),setS2(double),setS3(double),setS4(double)
-
getS2
double getS2()Get the second thin prism distortion coefficient S2.- Returns:
- the second thin prism distortion coefficient S2.
- See Also:
setS2(double),getS1(),getS3(),getS4()
-
setS2
void setS2(double s2)Set the second thin prism distortion coefficient S2.- Parameters:
s2- the second thin prism distortion coefficient S2.- See Also:
getS2(),setS1(double),setS3(double),setS4(double)
-
getS3
double getS3()Get the third thin prism distortion coefficient S3.- Returns:
- the third thin prism distortion coefficient S3.
- See Also:
setS3(double),getS1(),getS2(),getS4()
-
setS3
void setS3(double s3)Set the third thin prism distortion coefficient S3.- Parameters:
s3- the third thin prism distortion coefficient S3.- See Also:
getS3(),setS1(double),setS2(double),setS4(double)
-
getS4
double getS4()Get the fourth thin prism distortion coefficient S4.- Returns:
- the fourth thin prism distortion coefficient S4.
- See Also:
setS4(double),getS1(),getS2(),getS3()
-
setS4
void setS4(double s4)Set the fourth thin prism distortion coefficient S4.- Parameters:
s4- the fourth thin prism distortion coefficient S4.- See Also:
getS4(),setS1(double),setS2(double),setS3(double)
-
getTx
double getTx()Get the x axis tilt angular coefficient Tx.- Returns:
- the x axis tilt angular coefficient Tx.
- See Also:
setTx(double),getTy()
-
setTx
void setTx(double tx)Set the x axis tilt angular coefficient Tx.- Parameters:
tx- the x axis tilt angular coefficient Tx.- See Also:
getTx(),setTy(double)
-
getTy
double getTy()Get the y axis tilt angular coefficient Ty.- Returns:
- the y axis tilt angular coefficient Ty.
- See Also:
setTy(double),getTx()
-
setTy
void setTy(double ty)Set the y axis tilt angular coefficient Ty.- Parameters:
ty- the y axis tilt angular coefficient Ty.- See Also:
getTy(),setTx(double)
-
setDistortionCoefficients
void setDistortionCoefficients(double k1, double k2, double k3, double k4, double k5, double k6, double p1, double p2, double s1, double s2, double s3, double s4, double tx, double ty)Set the distortion coefficients.- Parameters:
k1- the first radial coefficientk2- the second radial coefficientk3- the third radial coefficientk4- the first radial rational coefficientk5- the second radial rational coefficientk6- the third radial rational coefficientp1- the first tangential coefficientp2- the second tangential coefficients1- the first thin prism distortion coefficients2- the second thin prism distortion coefficients3- the third thin prism distortion coefficients4- the fourth thin prism distortion coefficienttx- the x tilt distortion coefficientty- the y tilt distortion coefficient
-
setDistortionCoefficients
void setDistortionCoefficients(double k1, double k2, double k3, double k4, double k5, double k6, double p1, double p2, double s1, double s2, double s3, double s4)Set the radial, tangential and thin prism distortion coefficients. The tilt distortion coefficients τx and τx are set to 0.- Parameters:
k1- the first radial coefficientk2- the second radial coefficientk3- the third radial coefficientk4- the first radial rational coefficientk5- the second radial rational coefficientk6- the third radial rational coefficientp1- the first tangential coefficientp2- the second tangential coefficients1- the first thin prism distortion coefficients2- the second thin prism distortion coefficients3- the third thin prism distortion coefficients4- the fourth thin prism distortion coefficient
-
setDistortionCoefficients
void setDistortionCoefficients(double k1, double k2, double k3, double k4, double k5, double k6, double p1, double p2)Set the radial and tangential distortion coefficients. The thin prism and the tilt distortion coefficients s1, s2, s3, s4, τx and τx are set to 0.- Parameters:
k1- the first radial coefficientk2- the second radial coefficientk3- the third radial coefficientk4- the first radial rational coefficientk5- the second radial rational coefficientk6- the third radial rational coefficientp1- the first tangential coefficientp2- the second tangential coefficient
-
setDistortionCoefficients
void setDistortionCoefficients(double k1, double k2, double k3, double p1, double p2)Set the radial and tangential distortion coefficients. The radial rational, thin prism and the tilt distortion coefficients k4, k5, k6, s1, s2, s3, s4, τx and τx are set to 0.- Parameters:
k1- the first radial coefficientk2- the second radial coefficientk3- the third radial coefficientp1- the first tangential coefficientp2- the second tangential coefficient
-