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