Ask Your Question

Get Rotation and Translation Matrix

asked 2019-09-05 10:48:37 -0500

dbots94 gravatar image

I'm programming one Asus Xtion depth camera, wich instead of an RGB image, it gives me the Depth information.

I already have the Camera and Distortion Matrices of the depth camera, but now, I want to calibrate the vision system, by getting the rotation and translation matrices.

I already have the 3D local coordinates of the points, from the camera perspective, but now I need to convert them to world/global coordinates. Since this camera has only depth information I was thinking: is it possible to calibrate this vision system by saying where is the ground plane? How shoul I proceed to put the blue plane as the ground plane of my vison system?

image description
(note, in addition to the ground plane there's also an object on the plane)

I already tried using the solvePnP to get the rotation and translation matrices, but with no luck. Thanks in advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-09-18 12:17:16 -0500

dbots94 gravatar image

updated 2019-09-23 08:30:37 -0500

So looking for a solution on the Web I found that what I wish to do is called extrinsic calibration.

To find the best rotation/translation between two sets of 3D points, in the sense of minimizing the root mean square error, the solution is:

So, to transform 3D points from the camera reference frame, do the following:

  1. Define some 3D points with known position in the world reference frame, for example (but not necessarily) with Z=0. Put the coordinates in a Nx3 matrix P.
  2. Get the corresponding 3D points in the camera reference frame. Put them in a Nx3 matrix Q.
  3. From the file defined in point 3 above, call rigid_transform_3D(P, Q). This will return a 3x3 matrix R and a 3x1 vector t.

Then, for any 3D point in the camera reference frame p, as a 3x1 vector, you can obtain the corresponding world point, q with q =


In the first step, it only works if I have a standard for the location of the points (for example using a rectangle of known dimentions I would be able to find the correct world coordinates). Now assume that those points are chosen by a user by clicking on the 2D original Depth Image. For those points I would only know the local coordinates, not the global ones. So, how will I know the corresponding 3D world coordinates? Is there a way to say "I got some 3D camera coordinates that belong to the ground plane, find me the rotation matrix that projects those points to an horizontal plane"

THE RESPECTIVE SOLUTION:(taken from an answer to my question at

  1. Take the selected 3D points in camera reference frame, let's call them q'i.
  2. Fit a plane to these points, for example as described in The result of this will be a normal vector n. To fully specify the plane, you need also to choose a point, for example the centroid (average) of q'i.
  3. As the points surely don't perfectly lie in the plane, project them onto the plane, for example as described in: How to project a point onto a plane in 3D?. Let's call these projected points qi.
  4. At this point you have a set of 3D points, qi, that lie on a perfect plane, which should correspond closely to the ground plane (z=0 in world coordinate frame). The coordinates are in the camera reference frame, though.
  5. Now we need to specify an origin and the direction of the x and y axes in this ground plane. You don't seem to have any criteria for this, so an option is to arbitrarily set the origin just "below" the camera center, and align the ...
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-09-05 10:47:25 -0500

Seen: 2,214 times

Last updated: Sep 23 '19