cameraPoseToExtrinsics
(Not recommended) Convert camera pose to extrinsics
cameraPoseToExtrinsics
is not recommended. Use the pose2extr
function instead. For more information, see Version History.
Syntax
Description
returns a tform
= cameraPoseToExtrinsics(cameraPose
)rigid3d
object that contains the transformation
from world coordinates to camera coordinates. cameraPose
is
the orientation and location of the camera in world coordinates, specified as a
rigid3d
object.
[
returns the camera extrinsics, rotationMatrix
,translationVector
]
= cameraPoseToExtrinsics(orientation
,location
)rotationMatrix
and
translationVector
, which represent the coordinate
system transformation from world coordinates to camera coordinates. The inputs,
orientation
and location
,
represent the 3-D camera pose in the world coordinates.
Examples
Convert World Coordinates to Camera Coordinates
Create the 3-D orientation matrix and the location vector.
orientation = eye(3); location = [0 0 10];
Compute the rotation matrix and translation vector to transform points from world coordinates to camera coordinates.
[rotationMatrix,translationVector] = cameraPoseToExtrinsics(orientation,location)
rotationMatrix = 3×3
1 0 0
0 1 0
0 0 1
translationVector = 1×3
0 0 -10
Compute the transformation from world coordinates to camera coordinates as a rigid 3-D object.
cameraPose = rigid3d(orientation,location); tform = cameraPoseToExtrinsics(cameraPose)
tform = rigid3d with properties: Rotation: [3x3 double] Translation: [0 0 -10]
Input Arguments
cameraPose
— Orientation and location of the camera
rigid3d
object
Orientation and location of the camera in world coordinates, specified as
a rigid3d
object.
orientation
— 3-D orientation
3-by-3 matrix
3-D orientation of the camera in world coordinates, specified as a 3-by-3
matrix. The orientation
and
location
inputs must be the same data type.
Data Types: double
| single
location
— 3-D location
three-element vector
3-D location of the camera in world coordinates, specified as a
three-element vector. The orientation
and
location
inputs must be the same data type.
Data Types: double
| single
Output Arguments
tform
— Transformation
rigid3d
Transformation from world coordinates to camera coordinates, returned as a
rigid3d
object. The transformation allows you to transform
points from the world coordinate system to the camera coordinate system.
tform
is computed
as:
tform.Rotation = cameraPose.Rotation' tform.Translation = -cameraPose.Translation * cameraPose.Rotation'
rotationMatrix
— 3-D rotation
3-by-3 matrix
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 system to the camera coordinate system.
The relationship between the rotation matrix and the input orientation matrix is:
rotationMatrix =
orientation ' |
translationVector
— 3-D translation
1-by-3 vector
3-D translation, returned 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.
The relationship between the translation vector and the input orientation matrix is :
translationVector =
–location *orientation ' |
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 cameraPoseToExtrinsics
function uses the postmultiply convention. Although there are no plans to remove
cameraPoseToExtrinsics
at this time, you can streamline
your geometric transformation workflows by switching to the pose2extr
function, which supports the premultiply convention. For
more information, see Migrate Geometric Transformations to Premultiply Convention.
To update your code:
Change instances of the function name
cameraPoseToExtrinsics
topose2extr
.Specify the camera pose as a
rigidtform3d
object using thecameraPose
argument.pose2extr
does not support specifying the camera pose using theorientation
andtranslation
input arguments. Note that you create therigidtform3d
object using the transpose oforientation
or the transpose of the transformation matrix in theT
property oftform
.
Discouraged Usage | Recommended Replacement |
---|---|
This example specifies the camera pose as a rotation
matrix orientation = eye(3);
location = [0 0 10];
[rotationMatrixOld,translationVector] = cameraPoseToExtrinsics( ...
orientation',location) | This example specifies the camera pose as a
orientation = eye(3); location = [0 0 10]; cameraPose = rigidtform3d(orientation,location); extrinsics = pose2extr(cameraPose); If
you need to obtain a rotation matrix and translation vector,
then you can query properties of
rotationMatrix = extrinsics.R; translationVector = extrinsics.Translation; If
you want the rotation matrix in the postmultiply convention,
take the transpose of
rotationMatrixOld = extrinsics.R'; |
This example specifies a camera pose as a
A = [1 0 0 0; 0 1 0 0; 0 0 1 10; 0 0 0 1]; cameraPoseOld = rigid3d(A'); extrinsicsOld = cameraPoseToExtrinsics(cameraPoseOld); | This example specifies the camera pose as a
A = [1 0 0 0; 0 1 0 0; 0 0 1 10; 0 0 0 1]; cameraPose = rigidtform3d(A); extrinsics = pose2extr(cameraPose); If
instead you start with an existing T = cameraPoseOld.T; cameraPose = rigidtform3d(T'); extrinsics = pose2extr(cameraPose); |
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)