Main Content

cameraIntrinsicsKB

Intrinsic camera parameters based on Kannala-Brandt model

Since R2024a

Description

The cameraIntrinsicsKB object stores information about the intrinsic calibration parameters about the intrinsic calibration parameters, using the Kannala-Brandt [1] model, for a fisheye lens.

Creation

Create a cameraIntrinsicsKB object by using the cameraIntrinsicsFromOpenCV function.

Properties

expand all

This property is read-only.

Focal length, stored as a two-element vector of the form [fx fy], with values in pixels.

fx = Fsx

fy = Fsy

F is the focal length in world units, typically millimeters. sx and sy are the number of pixels per world unit in the x- and y-directions, respectively.

The focal length F influences the angle of view, and thus affects the area of the scene that appears focused in an image. For a fixed subject distance:

  • A short focal length offers a wide angle of view enabling the camera to capture a large area of the scene under focus. It emphasizes both the subject and the scene background.

  • A long focal length offers a narrow angle of view, thus reducing the area of the scene under focus. It emphasizes the subject more, and restricts the amount of background from captured by the camera.

For more information on how to set this property at object creation, see the intrinsicMatrix argument of the cameraIntrinsicsFromOpenCV function.

This property is read-only.

Optical center of the camera, stored as a two-element vector of the form [cx cy], with values in pixels. The vector contains the coordinates of the optical center of the camera.

For more information on how to set this property at object creation, see the intrinsicMatrix argument of the cameraIntrinsicsFromOpenCV function.

This property is read-only.

Image size produced by the camera, stored as a two-element vector of the form [mrows ncols]. Specify this value at object creation by using the imageSize argument of the cameraIntrinsicsFromOpenCV function.

This property is read-only.

Polynomial coefficients, stored as a four-element vector of the form [k1 k2 k3 k4]. These values specify the polynomial coefficients for the fisheye distortion function:

θd=θ(1+k1θ2+k2θ4+k3θ6+k4θ8)θ=atan(γ)

k1,k2,k3,k4

where k1, k2, k3, and k4 are the distortion coefficients of the lens.

For more information on how to set this property at object creation, see the distortionCoefficients argument of the cameraIntrinsicsFromOpenCV function.

This property is read-only.

Camera intrinsic matrix, stored as a 3-by-3 matrix. The matrix has this format:

[fx0cx0fycy001]

where cx and cy are the corresponding values of the PrincipalPoint, and fx and fy are the corresponding values of FocalLength.

For more information on how to set this property at object creation, see the intrinsicMatrix argument of the cameraIntrinsicsFromOpenCV function.

Examples

collapse all

Define OpenCV fisheye parameters in the workspace.

intrinsicMatrix = [875.88  0.00   1005.62; ...
                   0.00    874.76 741.52; ...
                   0.00,   0.00,  1.00];
distortionCoeffs = [0.08, -0.16, 0.35, -0.26];

Define the image size returned by the camera.

imageSize =[1500 2000];

Import the intrinsic camera parameters for a fisheye lens from OpenCV.

intrinsicsKB = cameraIntrinsicsFromOpenCV(intrinsicMatrix,distortionCoeffs,imageSize)
intrinsicsKB = 
  cameraIntrinsicsKB with properties:

               FocalLength: [875.8800 874.7600]
            PrincipalPoint: [1.0066e+03 742.5200]
                 ImageSize: [1500 2000]
    DistortionCoefficients: [0.0800 -0.1600 0.3500 -0.2600]
                         K: [3x3 double]

Load an image to undistort.

filename = fullfile(toolboxdir("vision"),"visiondata", ...
    "calibration","gopro","gopro01.jpg");
I = imread(filename);

Undistort the image and display the results.

J = undistortImage(I,intrinsicsKB);
imshowpair(I,J,"montage");
title("Original Image (left) vs. Corrected Image (right)");

Figure contains an axes object. The hidden axes object with title Original Image (left) vs. Corrected Image (right) contains an object of type image.

Algorithms

The Kannale-Brandt model extends the ideal pinhole model by accounting for lens distortion to represent a real camera.

The distorted points are (xdistorted, ydistorted), where:

xdistorted=θdγ×x

ydistorted=θdγ×y

The undistorted pixel locations in normalized image coordinates are (x,y), where:

γ2=x2+y2

θd=θ(1+k1θ2+k2θ4+k3θ6+k4θ8)θ=atan(γ)

k1,k2,k3,k4

where k1, k2, k3, and k4 are the distortion coefficients of the lens.

References

[1] Kannala, J., and S.S. Brandt. A Generic Camera Model and Calibration Method for Conventional, Wide-Angle, and Fish-Eye Lenses. IEEE Transactions on Pattern Analysis and Machine Intelligence 28, no. 8 (August 2006): 1335–40. https://doi.org/10.1109/TPAMI.2006.153.

Version History

Introduced in R2024a