java.lang.Object
imagingbook.calibration.zhang.Camera
A camera model with parameters as specified in Zhang's paper.
-
Constructor Summary
ConstructorsConstructorDescriptionCamera
(double[] s) Creates a standard camera from a vector of intrinsic parametersCamera
(double f, double uc, double vc) Creates a simple pinhole camera (with no distortion whatsoever).Camera
(double alpha, double beta, double gamma, double uc, double vc, double k0, double k1) Camera
(RealMatrix A, double[] K) Creates a standard camera from a transformation matrix and a vector of lens distortion coefficients. -
Method Summary
Modifier and TypeMethodDescriptiondouble
D
(double r) Radial distortion function, to be applied in the formgetA()
Returns a copy of the camera's inner transformation matrix with contentsdouble
getAlpha()
Returns the camera's alpha value.double
getBeta()
Returns the camera's beta value.double
getGamma()
Returns the camera's gamma value.getHomography
(ViewTransform view) Returns the homography for the given view as a 3 x 3 matrix.Returns the inverse of the camera intrinsic matrix A as a 3x3 matrix (without the last row {0,0,1}).double[]
getK()
Returns the camera's lens distortion coefficients.double[]
Returns the camera's inner parameters as a vector (alpha, beta, gamma, uc, vc, k0, k1).double
getUc()
Returns the camera's uc value.double
getVc()
Returns the camera's vc value.double[]
mapToSensorPlane
(double[] xyd) Maps from the ideal projection plane to sensor coordinates, using the camera's intrinsic parameters.double[]
project
(ViewTransform view, double[] XYZ) Projects the given 3D point onto the sensor plane of this camera for the provided extrinsic view parameters.double[]
project
(ViewTransform view, Pnt2d P) Projects the X/Y world point (in the Z = 0 plane) to image coordinates under the given camera view (extrinsic transformation parameters).Pnt2d[]
project
(ViewTransform view, Pnt2d[] PP) Projects the X/Y world points (all in the Z = 0 plane) to image coordinates under the given camera view (extrinsic transformation parameters).double[]
projectNormalized
(ViewTransform view, double[] XYZ) Projects the given 3D point to ideal projection coordinates for the provided extrinsic view parameters.double[]
projectNormalized
(ViewTransform view, Pnt2d P) Projects the given 3D point to ideal projection coordinates for the provided extrinsic view parameters.toString()
double
unwarp
(double R) Inverse radial distortion function.double[]
unwarp
(double[] xyd) Applies inverse radial distortion to a given point in the ideal image plane.double
warp
(double r) double[]
warp
(double[] xy) Applies radial distortion to a point in the ideal 2D projection.
-
Constructor Details
-
Camera
-
Camera
Creates a standard camera from a vector of intrinsic parameters- Parameters:
s
- a vector of intrinsic camera parameters (alpha, beta, gamma, uc, vc, k0, k1).
-
Camera
Creates a standard camera from a transformation matrix and a vector of lens distortion coefficients.- Parameters:
A
- the (min.) 2 x 3 matrix holding the intrinsic camera parametersK
- the radial distortion coefficients k0, k1, ... (may benull
)
-
Camera
Creates a simple pinhole camera (with no distortion whatsoever).- Parameters:
f
- the camera's focal length (in pixel units).uc
- the x-position of the optical axis intersecting the image plane (in pixel units)vc
- the y-position of the optical axis intersecting the image plane (in pixel units)
-
-
Method Details
-
project
Projects the X/Y world point (in the Z = 0 plane) to image coordinates under the given camera view (extrinsic transformation parameters).- Parameters:
view
- the extrinsic transformation parametersP
- a single X/Y world point (with Z = 0)- Returns:
- the projected 2D image coordinates
-
project
Projects the X/Y world points (all in the Z = 0 plane) to image coordinates under the given camera view (extrinsic transformation parameters).- Parameters:
view
- the extrinsic transformation parametersPP
- a set of X/Y world points (with Z = 0)- Returns:
- the projected 2D image coordinates
-
project
Projects the given 3D point onto the sensor plane of this camera for the provided extrinsic view parameters.- Parameters:
view
- the extrinsic camera (view) parametersXYZ
- a point in 3D world coordinates- Returns:
- the 2D sensor coordinates of the projected point
-
projectNormalized
Projects the given 3D point to ideal projection coordinates for the provided extrinsic view parameters. The world point is specified as a 2D coordinate in the Z = 0 plane.- Parameters:
view
- the extrinsic camera (view) parametersP
- a point in 3D world coordinates (Z = 0)- Returns:
- the 2D ideal projection
-
projectNormalized
Projects the given 3D point to ideal projection coordinates for the provided extrinsic view parameters.- Parameters:
view
- the extrinsic camera (view) parametersXYZ
- a point in 3D world coordinates- Returns:
- the 2D ideal projection
-
warp
-
warp
Applies radial distortion to a point in the ideal 2D projection.- Parameters:
xy
- a 2D point in the ideal projection- Returns:
- the lens-distorted position in the ideal projection
-
unwarp
Inverse radial distortion function. Finds the original (undistorted) radius r from the distorted radius R, both measured from the center = (0,0) of the ideal projection. Finds r as the root of the polynomialp(r) = - R + r + k0 * r^3 + k1 * r^5,
where R is constant, by using a Newton-Raphson solver.- Parameters:
R
- the distorted radius- Returns:
- the undistorted radius
-
unwarp
Applies inverse radial distortion to a given point in the ideal image plane.- Parameters:
xyd
- a distorted 2D point in the ideal image plane- Returns:
- the undistorted point
-
D
Radial distortion function, to be applied in the formr' = r * (1 + D(r))
to points in the ideal projection plane. Distortion coefficients k0, k1 are a property of the enclosingCamera
.- Parameters:
r
- the original radius of a point in the ideal projection plane- Returns:
- the pos/neg deviation for the given radius
-
mapToSensorPlane
Maps from the ideal projection plane to sensor coordinates, using the camera's intrinsic parameters.- Parameters:
xyd
- a 2D point on the ideal projection plane- Returns:
- the resulting 2D sensor coordinate
-
getParameterVector
Returns the camera's inner parameters as a vector (alpha, beta, gamma, uc, vc, k0, k1).- Returns:
- the camera's inner parameters
-
getAlpha
Returns the camera's alpha value.- Returns:
- alpha
-
getBeta
Returns the camera's beta value.- Returns:
- beta
-
getGamma
Returns the camera's gamma value.- Returns:
- gamma
-
getUc
Returns the camera's uc value.- Returns:
- uc
-
getVc
Returns the camera's vc value.- Returns:
- vc
-
getK
Returns the camera's lens distortion coefficients.- Returns:
- the vector of lens distortion coefficients
-
getA
Returns a copy of the camera's inner transformation matrix with contentsalpha gamma uc 0 beta vc
- Returns:
- the camara's inner transformation matrix (2 x 3)
-
getInverseA
Returns the inverse of the camera intrinsic matrix A as a 3x3 matrix (without the last row {0,0,1}). This version uses closed form matrix inversion. Used for rectifying images (i.e., removing lens distortion).- Returns:
- the inverse of the camera intrinsic matrix A
-
getHomography
Returns the homography for the given view as a 3 x 3 matrix.- Parameters:
view
- the extrinsic view parameters- Returns:
- the homography matrix
-
toString
-