AirSim icon indicating copy to clipboard operation
AirSim copied to clipboard

How to transform the world coordinates of an object to 2D coordinates on the camera frame?

Open flyers opened this issue 7 years ago • 4 comments

Hi,

I would like to get the 2D coordinates of an object in a certain camera frame. So far I know that the simGetObjectPose() can return the 3D pose of the object in the world frame and the simGetCameraInfo() can return the 3D pose of the certain camera, along with a 4 by 4 projection matrix. I am not sure what exactly is this 4 by 4 matrix because the camera projection matrix should be 4 by 3 usually. So how should I combine those things to get what I want. Does anyone have any ideas on it? Thanks for your help.

flyers avatar Dec 04 '18 14:12 flyers

Is this for Unity or Unreal? Not sure what your trying to do, but if this is in Unity and if for example you want to place a bull-eye sprite image on top of an object visible in the camera view you could do something like this https://docs.unity3d.com/ScriptReference/Camera.WorldToScreenPoint.html Sorry, I have no idea how to do this in Unreal.

jasonhbartlett avatar Dec 04 '18 22:12 jasonhbartlett

@jasonhbartlett Thanks for your help. However I want to achieve this in Unreal.

flyers avatar Dec 05 '18 08:12 flyers

If I remember correctly, there is an extra row in the projection matrix that just has a -1 at the end. However our projection matrix is not quite right unless the camera is pointing straight down. You'd have to use the FOV to compute the projection matrix yourself. In the meantime I'm entering this as a bug.

ironclownfish avatar Feb 14 '20 22:02 ironclownfish

Hi,

I would like to get the 2D coordinates of an object in a certain camera frame. So far I know that the simGetObjectPose() can return the 3D pose of the object in the world frame and the simGetCameraInfo() can return the 3D pose of the certain camera, along with a 4 by 4 projection matrix. I am not sure what exactly is this 4 by 4 matrix because the camera projection matrix should be 4 by 3 usually. So how should I combine those things to get what I want. Does anyone have any ideas on it? Thanks for your help.

Hi @flyers , Have you solved this problem?I am also confused about this 4X4 matrix . Thanks!

LIU-Xueming avatar Nov 05 '21 05:11 LIU-Xueming