0
votes

My problem is exactly the reverse of How to determine world coordinates of a camera?.

If R and t are the vector of orientation and position of the camera in the world space? How do I transform easily back to the same space like the rvec and tvec?

1
do you want to transform some real world point coordinates to local camera coordinares? have a look at computer graphics theory. afair it should be just to multiply the 3D point by the inverse of the camera matrix.Micka
look here Understanding 4x4 homogenous transform matrices just keep in mind that camera matrix is InverseSpektre
@Micka, because I made a mistake about what's [R|t] in the projection matrix. I calculated the R and t of the camera in the world space. So now I wish to transform them back to the camera space without coding too much.tomriddle_1234
in my understanding from "camera space" R is unit mat and t is zero everywhere for a camera in its own "camera space" (if points are given in camera space you can perform standard projection), but I might be wrong there...Micka

1 Answers

2
votes

If you say you do have an R and t in world space, then this is not very accurate.

However, let us assume that R and t (a 3x3 rotation matrix and 3x1 translation vector) represent the orientation and translation which are used to transform a point Xw in world space to a point in camera space Xc (no homogeneuos coordinates) :

Xc = R*Xw + t

These are the R and t, which are part of your projection matrix P (which is applicable with homogeneous coordinates) and the result of solvePnP (see Note at the bottom):

P = K[R|t]

The t is the world origin in camera space.

The other way round, to transform a point in camera space to world space, can be easily derived since the inverse of the orthogonal matrix R is R' (R transposed):

 Xw = R'*Xc - R't

As you can see R' (3x3 matrix) and - R't (3x1 vector) are now the orientation matrix respectively translation vector to transform from camera to world space (more precise - R't is the camera origin/center in world space often referred to as C).

Note: rvec is in the form of rotation vectors, as you may know Rodrigues() is used to switch between the two representations.