Main Content

cameraPoseToExtrinsics

Convert camera pose to extrinsics

Description

tform = cameraPoseToExtrinsics(cameraPose) returns a 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.

example

[rotationMatrix,translationVector] = cameraPoseToExtrinsics(orientation,location) returns the camera extrinsics, 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

collapse all

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

collapse all

Orientation and location of the camera in world coordinates, specified as a rigid3d object.

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

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

collapse all

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'

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'

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™.

Introduced in R2016b