Package org.jvision.camera.distortion
Class SimpleLensDistortionOpenCV
java.lang.Object
org.jvision.camera.distortion.SimpleLensDistortionOpenCV
- All Implemented Interfaces:
LensDistortion,LensDistortionOpenCV
A class dedicated to the handling of 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 -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new OpenCV lens distortion representation with no distortion.
An OpenCV distortion is made of 4 components: Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).SimpleLensDistortionOpenCV(double[] coefficients)Create a new distortion representation based onOpenCV formalizationwith given coefficients.
An OpenCV distortion is made of 4 components: Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).SimpleLensDistortionOpenCV(double k1, double k2, double k3, double p1, double p2)Create a new distortion representation based onOpenCV formalizationwith given coefficients.
An OpenCV distortion is made of 4 components: Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).SimpleLensDistortionOpenCV(double k1, double k2, double k3, double k4, double k5, double k6, double p1, double p2)Create a new distortion representation based onOpenCV formalizationwith given coefficients.
An OpenCV distortion is made of 4 components: Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).SimpleLensDistortionOpenCV(double k1, double k2, double k3, double k4, double k5, double k6, double p1, double p2, double s1, double s2, double s3, double s4)Create a new distortion representation based onOpenCV formalizationwith given coefficients.
An OpenCV distortion is made of 4 components: Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).SimpleLensDistortionOpenCV(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)Create a new distortion representation based onOpenCV formalizationwith given coefficients.
An OpenCV distortion is made of 4 components: Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).SimpleLensDistortionOpenCV(float[] coefficients)Create a new distortion representation based onOpenCV formalizationwith given coefficients.
An OpenCV distortion is made of 4 components: Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).SimpleLensDistortionOpenCV(org.jeometry.math.Vector coefficients)Create a new distortion representation based onOpenCV formalizationwith given coefficients.
An OpenCV distortion is made of 4 components: Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational). -
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.Vectororg.jeometry.math.VectorgetDistortionCoefficients(org.jeometry.math.Vector coefficients)double[]double[]getDistortionCoefficientsDouble(double[] coefficients)float[]float[]getDistortionCoefficientsFloat(float[] coefficients)intdoublegetK1()doublegetK2()doublegetK3()doublegetK4()doublegetK5()doublegetK6()doublegetP1()doublegetP2()doublegetS1()doublegetS2()doublegetS3()doublegetS4()doublegetTx()doublegetTy()voidsetDistortionCoefficients(double[] parameters)voidsetDistortionCoefficients(double k1, double k2, double k3, double p1, double p2)voidsetDistortionCoefficients(double k1, double k2, double k3, double k4, double k5, double k6, double p1, double p2)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)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)voidsetDistortionCoefficients(float[] coefficients)voidsetDistortionCoefficients(org.jeometry.math.Vector coefficients)voidsetK1(double k1)voidsetK2(double k2)voidsetK3(double k3)voidsetK4(double k4)voidsetK5(double k5)voidsetK6(double k6)voidsetP1(double p1)voidsetP2(double p2)voidsetS1(double s1)voidsetS2(double s2)voidsetS3(double s3)voidsetS4(double s4)voidsetTx(double tx)voidsetTy(double ty)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 corrected)
-
Constructor Details
-
SimpleLensDistortionOpenCV
public SimpleLensDistortionOpenCV()Create a new OpenCV lens distortion representation with no distortion.
An OpenCV distortion is made of 4 components:- Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).
- Tangential (decentering) distortion defined by coefficients p1 and p2.
- Thin prism distortion defined by coefficients s1, s2, s3 and s4
- Tilt distortion defined by coefficients τx and τy.
-
SimpleLensDistortionOpenCV
public SimpleLensDistortionOpenCV(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)Create a new distortion representation based onOpenCV formalizationwith given coefficients.
An OpenCV distortion is made of 4 components:- Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).
- Tangential (decentering) distortion defined by coefficients p1 and p2.
- Thin prism distortion defined by coefficients s1, s2, s3 and s4
- Tilt distortion defined by coefficients τx and τy.
- Parameters:
k1- the first radial distortion simple coefficientk2- the second radial distortion simple coefficientk3- the third radial distortion simple coefficientk4- the first radial distortion rational coefficientk5- the second radial distortion rational coefficientk6- the third radial distortion rational coefficientp1- the first tangential (decentering) distortion coefficientp2- the second tangential (decentering) distortion 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
-
SimpleLensDistortionOpenCV
public SimpleLensDistortionOpenCV(double k1, double k2, double k3, double k4, double k5, double k6, double p1, double p2, double s1, double s2, double s3, double s4)Create a new distortion representation based onOpenCV formalizationwith given coefficients.
An OpenCV distortion is made of 4 components:- Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).
- Tangential (decentering) distortion defined by coefficients p1 and p2.
- Thin prism distortion defined by coefficients s1, s2, s3 and s4
- Tilt distortion defined by coefficients τx and τy.
- Parameters:
k1- the first radial distortion simple coefficientk2- the second radial distortion simple coefficientk3- the third radial distortion simple coefficientk4- the first radial distortion rational coefficientk5- the second radial distortion rational coefficientk6- the third radial distortion rational coefficientp1- the first tangential (decentering) distortion coefficientp2- the second tangential (decentering) distortion 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
-
SimpleLensDistortionOpenCV
public SimpleLensDistortionOpenCV(double k1, double k2, double k3, double k4, double k5, double k6, double p1, double p2)Create a new distortion representation based onOpenCV formalizationwith given coefficients.
An OpenCV distortion is made of 4 components:- Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).
- Tangential (decentering) distortion defined by coefficients p1 and p2.
- Thin prism distortion defined by coefficients s1, s2, s3 and s4
- Tilt distortion defined by coefficients τx and τy.
- Parameters:
k1- the first radial distortion simple coefficientk2- the second radial distortion simple coefficientk3- the third radial distortion simple coefficientk4- the first radial distortion rational coefficientk5- the second radial distortion rational coefficientk6- the third radial distortion rational coefficientp1- the first tangential (decentering) distortion coefficientp2- the second tangential (decentering) distortion coefficient
-
SimpleLensDistortionOpenCV
public SimpleLensDistortionOpenCV(double k1, double k2, double k3, double p1, double p2)Create a new distortion representation based onOpenCV formalizationwith given coefficients.
An OpenCV distortion is made of 4 components:- Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).
- Tangential (decentering) distortion defined by coefficients p1 and p2.
- Thin prism distortion defined by coefficients s1, s2, s3 and s4
- Tilt distortion defined by coefficients τx and τy.
- Parameters:
k1- the first radial distortion simple coefficientk2- the second radial distortion simple coefficientk3- the third radial distortion simple coefficientp1- the first tangential (decentering) distortion coefficientp2- the second tangential (decentering) distortion coefficient
-
SimpleLensDistortionOpenCV
public SimpleLensDistortionOpenCV(org.jeometry.math.Vector coefficients)Create a new distortion representation based onOpenCV formalizationwith given coefficients.
An OpenCV distortion is made of 4 components:- Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).
- Tangential (decentering) distortion defined by coefficients p1 and p2.
- Thin prism distortion defined by coefficients s1, s2, s3 and s4
- Tilt distortion defined by coefficients τx and τy.
- (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
- Parameters:
coefficients- the distortion coefficients- Throws:
IllegalArgumentException- if the input array does not match a distortion configuration
-
SimpleLensDistortionOpenCV
public SimpleLensDistortionOpenCV(float[] coefficients)Create a new distortion representation based onOpenCV formalizationwith given coefficients.
An OpenCV distortion is made of 4 components:- Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).
- Tangential (decentering) distortion defined by coefficients p1 and p2.
- Thin prism distortion defined by coefficients s1, s2, s3 and s4
- Tilt distortion defined by coefficients τx and τy.
- [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
- Parameters:
coefficients- the distortion coefficients- Throws:
IllegalArgumentException- if the input array does not match a distortion configuration
-
SimpleLensDistortionOpenCV
public SimpleLensDistortionOpenCV(double[] coefficients)Create a new distortion representation based onOpenCV formalizationwith given coefficients.
An OpenCV distortion is made of 4 components:- Radial distortion defined by coefficients k1, k2, k3 (simple) and k4, k5, k6 (rational).
- Tangential (decentering) distortion defined by coefficients p1 and p2.
- Thin prism distortion defined by coefficients s1, s2, s3 and s4
- Tilt distortion defined by coefficients τx and τy.
- [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
- Parameters:
coefficients- the distortion coefficients- Throws:
IllegalArgumentException- if the input array does not match a distortion configuration
-
-
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, org.jeometry.geom2D.point.Point2D distorted)- Specified by:
distortin interfaceLensDistortion- Specified by:
distortin interfaceLensDistortionOpenCV
-
distort
public org.jeometry.geom2D.point.Point2D distort(org.jeometry.geom2D.point.Point2D undistorted)- Specified by:
distortin interfaceLensDistortion- Specified by:
distortin interfaceLensDistortionOpenCV
-
undistort
public org.jeometry.geom2D.point.Point2D undistort(org.jeometry.geom2D.point.Point2D distorted)- Specified by:
undistortin interfaceLensDistortion- Specified by:
undistortin interfaceLensDistortionOpenCV
-
undistort
public org.jeometry.geom2D.point.Point2D undistort(org.jeometry.geom2D.point.Point2D distorted, org.jeometry.geom2D.point.Point2D corrected)- Specified by:
undistortin interfaceLensDistortion- Specified by:
undistortin interfaceLensDistortionOpenCV
-
getDistortionCoefficients
public org.jeometry.math.Vector getDistortionCoefficients()- Specified by:
getDistortionCoefficientsin interfaceLensDistortion- Specified by:
getDistortionCoefficientsin interfaceLensDistortionOpenCV
-
getDistortionCoefficients
public org.jeometry.math.Vector getDistortionCoefficients(org.jeometry.math.Vector coefficients) throws IllegalArgumentException- Specified by:
getDistortionCoefficientsin interfaceLensDistortion- Specified by:
getDistortionCoefficientsin interfaceLensDistortionOpenCV- Throws:
IllegalArgumentException
-
setDistortionCoefficients
public void setDistortionCoefficients(org.jeometry.math.Vector coefficients) throws IllegalArgumentException- Specified by:
setDistortionCoefficientsin interfaceLensDistortion- Specified by:
setDistortionCoefficientsin interfaceLensDistortionOpenCV- Throws:
IllegalArgumentException
-
getDistortionCoefficientsFloat
public float[] getDistortionCoefficientsFloat()- Specified by:
getDistortionCoefficientsFloatin interfaceLensDistortion- Specified by:
getDistortionCoefficientsFloatin interfaceLensDistortionOpenCV
-
getDistortionCoefficientsFloat
public float[] getDistortionCoefficientsFloat(float[] coefficients) throws IllegalArgumentException- Specified by:
getDistortionCoefficientsFloatin interfaceLensDistortion- Specified by:
getDistortionCoefficientsFloatin interfaceLensDistortionOpenCV- Throws:
IllegalArgumentException
-
setDistortionCoefficients
- Specified by:
setDistortionCoefficientsin interfaceLensDistortion- Specified by:
setDistortionCoefficientsin interfaceLensDistortionOpenCV- Throws:
IllegalArgumentException
-
getDistortionCoefficientsDouble
public double[] getDistortionCoefficientsDouble()- Specified by:
getDistortionCoefficientsDoublein interfaceLensDistortion- Specified by:
getDistortionCoefficientsDoublein interfaceLensDistortionOpenCV
-
getDistortionCoefficientsDouble
public double[] getDistortionCoefficientsDouble(double[] coefficients) throws IllegalArgumentException- Specified by:
getDistortionCoefficientsDoublein interfaceLensDistortion- Specified by:
getDistortionCoefficientsDoublein interfaceLensDistortionOpenCV- Throws:
IllegalArgumentException
-
setDistortionCoefficients
- Specified by:
setDistortionCoefficientsin interfaceLensDistortion- Specified by:
setDistortionCoefficientsin interfaceLensDistortionOpenCV- Throws:
IllegalArgumentException
-
getK1
public double getK1()- Specified by:
getK1in interfaceLensDistortionOpenCV
-
setK1
public void setK1(double k1)- Specified by:
setK1in interfaceLensDistortionOpenCV
-
getK2
public double getK2()- Specified by:
getK2in interfaceLensDistortionOpenCV
-
setK2
public void setK2(double k2)- Specified by:
setK2in interfaceLensDistortionOpenCV
-
getK3
public double getK3()- Specified by:
getK3in interfaceLensDistortionOpenCV
-
setK3
public void setK3(double k3)- Specified by:
setK3in interfaceLensDistortionOpenCV
-
getK4
public double getK4()- Specified by:
getK4in interfaceLensDistortionOpenCV
-
setK4
public void setK4(double k4)- Specified by:
setK4in interfaceLensDistortionOpenCV
-
getK5
public double getK5()- Specified by:
getK5in interfaceLensDistortionOpenCV
-
setK5
public void setK5(double k5)- Specified by:
setK5in interfaceLensDistortionOpenCV
-
getK6
public double getK6()- Specified by:
getK6in interfaceLensDistortionOpenCV
-
setK6
public void setK6(double k6)- Specified by:
setK6in interfaceLensDistortionOpenCV
-
getP1
public double getP1()- Specified by:
getP1in interfaceLensDistortionOpenCV
-
setP1
public void setP1(double p1)- Specified by:
setP1in interfaceLensDistortionOpenCV
-
getP2
public double getP2()- Specified by:
getP2in interfaceLensDistortionOpenCV
-
setP2
public void setP2(double p2)- Specified by:
setP2in interfaceLensDistortionOpenCV
-
getS1
public double getS1()- Specified by:
getS1in interfaceLensDistortionOpenCV
-
setS1
public void setS1(double s1)- Specified by:
setS1in interfaceLensDistortionOpenCV
-
getS2
public double getS2()- Specified by:
getS2in interfaceLensDistortionOpenCV
-
setS2
public void setS2(double s2)- Specified by:
setS2in interfaceLensDistortionOpenCV
-
getS3
public double getS3()- Specified by:
getS3in interfaceLensDistortionOpenCV
-
setS3
public void setS3(double s3)- Specified by:
setS3in interfaceLensDistortionOpenCV
-
getS4
public double getS4()- Specified by:
getS4in interfaceLensDistortionOpenCV
-
setS4
public void setS4(double s4)- Specified by:
setS4in interfaceLensDistortionOpenCV
-
getTx
public double getTx()- Specified by:
getTxin interfaceLensDistortionOpenCV
-
setTx
public void setTx(double tx)- Specified by:
setTxin interfaceLensDistortionOpenCV
-
getTy
public double getTy()- Specified by:
getTyin interfaceLensDistortionOpenCV
-
setTy
public void setTy(double ty)- Specified by:
setTyin interfaceLensDistortionOpenCV
-
setDistortionCoefficients
public 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)- Specified by:
setDistortionCoefficientsin interfaceLensDistortionOpenCV
-
setDistortionCoefficients
public 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)- Specified by:
setDistortionCoefficientsin interfaceLensDistortionOpenCV
-
setDistortionCoefficients
public void setDistortionCoefficients(double k1, double k2, double k3, double k4, double k5, double k6, double p1, double p2)- Specified by:
setDistortionCoefficientsin interfaceLensDistortionOpenCV
-
setDistortionCoefficients
public void setDistortionCoefficients(double k1, double k2, double k3, double p1, double p2)- Specified by:
setDistortionCoefficientsin interfaceLensDistortionOpenCV
-