castacks / tartanair_tools

TartanAir dataset tools and samples
http://theairlab.org/tartanair-dataset
BSD 3-Clause "New" or "Revised" License
308 stars 34 forks source link

Transformation from NED to Cam #37

Closed amin-abouee closed 3 months ago

amin-abouee commented 2 years ago

Hi, Tartain air is my training dataset for a deep learning odometry project. In your dataset, the poses are in NED coordinate while I need to convert them to camera (opencv) coordinate system[right-down-forward]. For this purpose, you also implemented a function as ned2cam that converts a ned trajectory into my desired camera coordinate system. So the question is, why do you need to apply the right multiplication (.dot(T_inv)) for this transformation : ttt=T.dot(tt).dot(T_inv).

When you have the pose of a frame with respect to a world pose in NED coordinate, you just need to apply the transformation from NED to Cam (T matrix in your formula) to have it in Cam coordinate! So then, what is the point of T_inv there?
Notepad5_1

ccj5351 commented 7 months ago

I think the code in ned2cam is correct.

In short:

$T^{w}_{c}$ = $T^{w}_{wned}$ * $T^{wned}_{cned}$* $T^{cned}_{c}$ =`T.dot(tt).dot(T_inv)` (as what you mentioned in the function `ned2cam`)

Assume we have the following coordinate systems:

Transformation from NED to OpenCV Style Coordinate System

Why do we need OpenCV style camera pose?

It is because we use the following pipeline to connect RGB, camera and world:

RGB image $(x,y)$ with $x$ to right, $y$ down, and image origin in the left-top corner ---> camera intrinsic K and inverse invK ---> camera points $P^{c}$ = $(X^{c}, Y^{c},Z^{c})$ ---> camera extrinsic E and inverse invE ---> world points $P^{w}$ = $(X^{w}, Y^{w},Z^{w})$.

How to get the transformation matrix from NED to OpenCV Style

$P^{w}$ = $T^{w}_{wned}$ * $P^{wned}$

$P^{c}$ = $T^{c}_{cned}$ * $P^{cned}$

amin-abouee commented 3 months ago

Thanks for your answer