Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

extrinsics

Compute location of calibrated camera

Syntax

  • [rotationMatrix,translationVector] = extrinsics(imagePoints,worldPoints,cameraParams)
    example

Description

example

[rotationMatrix,translationVector] = extrinsics(imagePoints,worldPoints,cameraParams) returns the 3-D rotation matrix and the 3-D translation vector to allow you to transform points from the world coordinate to the camera coordinate system.

Code Generation Support:
Supports Code Generation: Yes
Supports MATLAB Function block: No
Code Generation Support, Usage Notes, and Limitations

Examples

collapse all

Load calibration images.

numImages = 9;
files = cell(1, numImages);
 for i = 1:numImages
    files{i} = fullfile(matlabroot, 'toolbox', 'vision', 'visiondata', 'calibration', 'slr', sprintf('image%d.jpg', i));
 end

Detect the checkerboard corners in the images.

[imagePoints, boardSize] = detectCheckerboardPoints(files);

Generate the world coordinates of the checkerboard corners in the pattern-centric coordinate system, with the upper-left corner at (0,0).

squareSize = 29; % in millimeters
worldPoints = generateCheckerboardPoints(boardSize, squareSize);

Calibrate the camera.

cameraParams = estimateCameraParameters(imagePoints, worldPoints);

Load image at new location.

imOrig = imread(fullfile(matlabroot, 'toolbox', 'vision', 'visiondata', 'calibration', 'slr', 'image9.jpg'));
figure; imshow(imOrig);
title('Input Image');

Undistort image.

im = undistortImage(imOrig, cameraParams);

Find reference object in new image.

[imagePoints, boardSize] = detectCheckerboardPoints(im);

Compute new extrinsics.

[rotationMatrix, translationVector] = extrinsics(imagePoints, worldPoints, cameraParams)
rotationMatrix =

    0.1421   -0.7439    0.6530
    0.9661   -0.0392   -0.2550
    0.2153    0.6671    0.7131


translationVector =

  -28.5034   30.9556  722.8184

Related Examples

Input Arguments

collapse all

Image coordinates of points, specified as an M-by-2 array. The array contains M number of [x, y] coordinates. The imagePoints and worldPoints inputs must both be double or both be single.

Data Types: single | double

World coordinates corresponding to image coordinates, specified as an M-by-2 matrix. The imagePoints and worldPoints inputs must both be double or both be single. The function assumes that the points are coplanar with z= 0 and the number of points, M, must be at least 4.

Data Types: single | double

Object for storing camera parameters, specified as a cameraParameters returned by the estimateCameraParameters function or the Camera Calibrator app. This object contains the intrinsic, extrinsic, and lens distortion parameters of a camera.

Output Arguments

collapse all

3-D rotation, returned as a 3-by-3 matrix. The rotation matrix together with the translation vector allows you to transform points from the world coordinate to the camera coordinate system.

If you set the imagePoints and worldPoints inputs to class double, then the function returns the rotationMatrix and translationVector as double. Otherwise, they are single.

3-D translation, returned as a 1-by-3 vector.

If you set the imagePoints and worldPoints inputs to class double, then the function returns the rotationMatrix and translationVector as double. Otherwise, they are single.

More About

collapse all

Algorithms

The extrinsics function uses two different algorithms to compute the extrinsics depending on whether worldPoints are specified as an M-by-2 or an M-by-3 matrix. The algorithm for the M-by-3 case requires the points to be non-coplanar. It will produce incorrect results if the worldPoints are coplanar. Use an M-by-2 matrix for coplanar points where z= 0.

The extrinsics function computes the rotation matrix and translation vector for a single image in closed form. During calibration, the extrinsics are estimated numerically to minimize the reprojection errors for all calibration images. Therefore, using the extrinsics function on one of the calibration images returns rotation matrix and translation vector slightly different from the ones obtained during calibration.

Introduced in R2014a

Was this topic helpful?