extrinsicsToCameraPose
(Not recommended) Convert extrinsics to camera pose
extrinsicsToCameraPose
is not recommended. Use the extr2pose
function instead. For more information, see Version History.
Syntax
Description
returns a cameraPose
= extrinsicsToCameraPose(tform
)rigid3d
object that contains the camera pose,
cameraPose
, in world coordinates.
tform
is a transformation from world coordinates to camera
coordinates, specified as a rigid3d
object.
[
returns 3-D camera pose orientation and location in world coordinates. The inputs,
orientation
,location
]
= extrinsicsToCameraPose(rotationMatrix
,translationVector
)rotationMatrix
and translationVector
,
represent the transformation from world coordinates to camera coordinates.
Examples
Convert Camera Coordinates to World Coordinates
Create a rotation matrix and a translation vector.
rotationMatrix = eye(3); translationVector = [0 0 -10];
Compute the camera orientation matrix and location vector in world coordinates.
[orientation,location] = extrinsicsToCameraPose(rotationMatrix,translationVector)
orientation = 3×3
1 0 0
0 1 0
0 0 1
location = 1×3
0 0 10
Compute the camera pose in world coordinates as a rigid 3-D object.
tform = rigid3d(rotationMatrix,translationVector); cameraPose = extrinsicsToCameraPose(tform)
cameraPose = rigid3d with properties: Rotation: [3x3 double] Translation: [0 0 10]
Input Arguments
tform
— Transformation
rigid3d
object
Transformation from world coordinates to camera coordinates, specified as
a rigid3d
object. The transformation allows you to transform
points from the world coordinate system to the camera coordinate
system.
rotationMatrix
— 3-D rotation
3-by-3 matrix
3-D rotation, specified as a 3-by-3 matrix. The rotation matrix, together with the translation vector allows you to transform points from the world coordinate system to the camera coordinate system.
Data Types: double
| single
translationVector
— 3-D translation
1-by-3 vector
3-D translation, specified as a 1-by-3 vector. The translation vector together with the rotation matrix, enables you to transform points from the world coordinate system to the camera coordinate system.
Data Types: double
| single
Output Arguments
cameraPose
— Camera pose
rigid3d
object
Camera pose in world coordinates, returned as a rigid3d
object. cameraPose
is computed
as:
cameraPose.Rotation = tform.Rotation' cameraPose.Translation = -tform.Translation * tform.Rotation'
orientation
— 3-D orientation
3-by-3 matrix
3-D orientation of the camera in world coordinates, returned as a 3-by-3 matrix.
The relationship between the rotation matrix and the output orientation matrix is:
orientation =
rotationMatrix ' |
location
— 3-D location
3-element vector
3-D location of the camera in world coordinates, specified as a three-element vector.
The relationship between the translation vector and the output orientation matrix is:
location
=
–translationVector
*rotationMatrix
'
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2016bR2022b: Not recommended
Starting in R2022b, most Computer Vision Toolbox™ functions create and perform geometric transformations using the
premultiply convention. However, the extrinsicsToCameraPose
function uses the postmultiply convention. Although there are no plans to remove
extrinsicsToCameraPose
at this time, you can streamline
your geometric transformation workflows by switching to the extr2pose
function, which supports the premultiply convention. For
more information, see Migrate Geometric Transformations to Premultiply Convention.
Change instances of the function name
cameraPoseToExtrinsics
topose2extr
.Specify the extrinsics as a
rigidtform3d
object using theextrinsics
argument.extr2pose
does not support specifying extrinsics using therotationMatrix
andtranslationVector
input arguments. Note that you create therigidtform3d
object using the transpose ofrotationMatrix
or the transpose of the transformation matrix in theT
property oftform
.
Discouraged Usage | Recommended Replacement |
---|---|
This example specifies the extrinsics as a rotation
matrix rotationMatrix = eye(3);
translationVector = [0 0 -10];
[orientationOld,location] = ...
extrinsicsToCameraPose(rotationMatrix',translationVector) | This example specifies extrinsics as a
rotationMatrix = eye(3); translationVector = [0 0 -10]; extrinsics = rigidtform3d(orientation,location); cameraPose = extr2pose(extrinsics); If
you need to obtain the camera orientation and location, then
you can query properties of
orientation = cameraPose.R; location = cameraPose.Translation; If
you want the orientation in the postmultiply convention,
take the transpose of
orientationOld = cameraPose.R; |
This example specifies extrinsics as a
A = [1 0 0 0; 0 1 0 0; 0 0 1 -10; 0 0 0 1]; extrinsicsOld = rigid3d(A'); cameraPoseOld = extrinsicsToCameraPose(extrinsicsOld); | This example specifies extrinsics as a
A = [1 0 0 0; 0 1 0 0; 0 0 1 -10; 0 0 0 1]; extrinsics = rigidtform3d(A); cameraPose = extr2pose(extrinsics); If
instead you start with an existing T = extrinsicsOld.T; extrinsics = rigidtform3d(T'); cameraPose = extr2pose(extrinsics); |
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)