estimateMonoCameraParameters

Estimate extrinsic monocular camera parameters using checkerboard

Syntax

[pitch,yaw,roll,height] = estimateMonoCameraParameters(intrinsics,imagePoints,worldPoints,patternOriginHeight)
[pitch,yaw,roll,height] = estimateMonoCameraParameters(___,Name,Value)

Description

example

[pitch,yaw,roll,height] = estimateMonoCameraParameters(intrinsics,imagePoints,worldPoints,patternOriginHeight) estimates the extrinsic parameters of a monocular camera using the intrinsic parameters of the camera and a checkerboard calibration pattern. The returned extrinsic parameters define the yaw, pitch, and roll rotation angles between the camera coordinate system (Computer Vision Toolbox) and vehicle coordinate system axes. Also defined is the height of the camera above the ground. Specify the intrinsic parameters, the image and world coordinates of corner points in the checkerboard pattern, and the height of the checkerboard pattern's origin above the ground.

By default, the function assumes that the camera is facing forward and that the checkerboard pattern is parallel with the ground. For all possible camera and checkerboard placements, see Calibrate a Monocular Camera.

[pitch,yaw,roll,height] = estimateMonoCameraParameters(___,Name,Value) specifies options using one or more name-value pairs, in addition to the inputs and outputs from the previous syntax. For example, you can specify the orientation or position of the checkerboard pattern.

Examples

collapse all

Configure a monocular fisheye camera by removing lens distortion and then estimating the camera's extrinsic parameters. Use an image of a checkerboard as the calibration pattern. For a more detailed look at how to configure a monocular camera that has a fisheye lens, see the Configure Monocular Fisheye Camera example.

Load the intrinsic parameters of a monocular camera that has a fisheye lens. intrinsics is a fisheyeIntrinsics object.

ld = load('fisheyeCameraIntrinsics');
intrinsics = ld.intrinsics;

Load an image of a checkerboard pattern that is placed flat on the ground. This image is for illustrative purposes and was not taken from a camera mounted to the vehicle. In a camera mounted to the vehicle, the X-axis of the pattern points to the right of the vehicle, and the Y-axis of the pattern points to the camera. Display the image.

imageFileName = fullfile(toolboxdir('driving'),'drivingdata','checkerboard.png');
I = imread(imageFileName);
imshow(I)

Detect the coordinates of the checkerboard corners in the image.

[imagePoints,boardSize] = detectCheckerboardPoints(I);

Generate the corresponding world coordinates of the corners.

squareSize = 0.029; % Square size in meters
worldPoints = generateCheckerboardPoints(boardSize,squareSize);

Estimate the extrinsic parameters required to configure the monoCamera object. Because the checkerboard pattern is directly on the ground, set the height of the pattern's origin to 0.

patternOriginHeight = 0;
[pitch,yaw,roll,height] = estimateMonoCameraParameters(intrinsics, ...
                             imagePoints,worldPoints,patternOriginHeight);

Because monoCamera does not accept fisheyeIntrinsics objects, remove distortion from the image and compute new intrinsic parameters from the undistorted image. camIntrinsics is an cameraIntrinsics object. Display the image to confirm distortion is removed.

[undistortedI,camIntrinsics] = undistortFisheyeImage(I,intrinsics,'Output','full');
imshow(undistortedI)

Configure the monocular camera using the estimated parameters.

monoCam = monoCamera(camIntrinsics,height,'Pitch',pitch,'Yaw',yaw,'Roll',roll)
monoCam = 
  monoCamera with properties:

        Intrinsics: [1x1 cameraIntrinsics]
        WorldUnits: 'meters'
            Height: 0.4447
             Pitch: 21.8459
               Yaw: -3.6130
              Roll: -3.1707
    SensorLocation: [0 0]

Input Arguments

collapse all

Intrinsic camera parameters, specified as a cameraIntrinsics or fisheyeIntrinsics object.

Checkerboard pattern images produced by these cameras can include lens distortion, which can affect the accuracy of corner point detections. To remove lens distortion and compute new intrinsic parameters, use these functions:

Image coordinates of checkerboard corner points, specified as an M-by-2 matrix of M number of [x y] vectors. These points must come from an image captured by a monocular camera. To detect these points in an image, use the detectCheckerboardPoints function.

estimateMonoCameraParameters assumes that all points in worldPoints are in the (XP, YP) plane and that M is greater than or equal to 4. To specify the height of the (XP, YP) plane above the ground, use patternOriginHeight.

Data Types: single | double

World coordinates of the corner points in the checkerboard, specified as an M-by-2 matrix of M number of [x y] vectors.

estimateMonoCameraParameters assumes that all points in worldPoints are in the (XP, YP) plane and that M is greater than or equal to 4. To specify the height of the (XP, YP) plane above the ground, use patternOriginHeight.

Point (0,0) corresponds to the bottom-right corner of the top-left square of the checkerboard.

Data Types: single | double

Height of the checkerboard pattern's origin above the ground, specified as a nonnegative real scalar. The origin is the bottom-right corner of the top-left square of the checkerboard. If the pattern is on the ground, set patternOriginHeight to 0.

Data Types: single | double

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'PatternOrientation','vertical','PatternPosition','right'

Orientation of the checkerboard pattern relative to the ground, specified as the comma-separated pair consisting of 'PatternOrientation' and one of the following:

  • 'horizontal' — Checkerboard pattern is parallel to the ground.

  • 'vertical' — Checkerboard pattern is perpendicular to the ground.

Position of the checkerboard pattern relative to the ground, specified as the comma-separated pair consisting of 'PatternPosition' and one of the following:

  • 'front' — Checkerboard pattern is in front of the vehicle.

  • 'back' — Checkerboard pattern is behind the vehicle.

  • 'left' — Checkerboard pattern is to the left of the vehicle.

  • 'right' — Checkerboard pattern is to the right of the vehicle.

Output Arguments

collapse all

Pitch angle between the horizontal plane of the vehicle and the optical axis of the camera, returned as a real scalar in degrees. pitch uses the ISO convention for rotation, with a clockwise positive angle direction when looking in the positive direction of the vehicle's YV-axis.

For more details, see Angle Directions.

Yaw angle between the XV-axis of the vehicle and the optical axis of the camera, returned as a real scalar in degrees. yaw uses the ISO convention for rotation, with a clockwise positive angle direction when looking in the positive direction of the vehicle's ZV-axis.

For more details, see Angle Directions.

Roll angle of the camera around its optical axis, returned as a real scalar in degrees. roll uses the ISO convention for rotation, with a clockwise positive angle direction when looking in the positive direction of the vehicle's XV-axis.

For more details, see Angle Directions.

Perpendicular height from the ground to the focal point of the camera, returned as a nonnegative real scalar in world units, such as meters.

More About

collapse all

Vehicle Coordinate System

In the vehicle coordinate system (XV, YV, ZV) defined by a monoCamera object:

  • The XV-axis points forward from the vehicle.

  • The YV-axis points to the left, as viewed when facing forward.

  • The ZV-axis points up from the ground to maintain the right-handed coordinate system.

By default, the origin of this coordinate system is on the road surface, directly below the camera center (focal point of camera).

To obtain more reliable results from estimateMonoCameraParameters, the checkerboard pattern must be placed in precise locations relative to this coordinate system. For more details, see Calibrate a Monocular Camera.

Angle Directions

The monocular camera sensor uses clockwise positive angle directions when looking in the positive direction of the Z-, Y-, and X-axes, respectively.

Introduced in R2018b