# Get object center pose in camera frame / viewport

Hello,

Is there some sort of function or code to retrieve the center position of an object not in world coordinates, but in my 2D image? I know how to retrieve the world pose, but am yet to find a solution to get the center position of the object for my neural network training. Is there anything existing that either just gives the object center pose of my asset directly or some kind of factor I can use to calculate from world position into camera pixels?

Thank you!

Hi there,

using the cameraViewTransform and the cameraProjection from the camera parameters annotator you can transform the world coordinates of the object to camera coordinates by multiplying the objects pose with the inverse of the view transform matrix.

You can then apply the camera projection by multiplying the resulting camera coordinates with the projection matrix. Projecting the 3D coordinate onto the 2D image plane. Resulting in a 4-d coordinate vector [x, y, z, w] (where w is the scaling factor).

To get the position of the object in the camera’s view frustum, with respect to the camera’s coord. system you should divide [x, y, z, w] with w resulting in [x’, y’, z’] (normalised coordinates).

For the pixel coordinate conversion [u, v], normalize [x’, y’, z’] by dividing by z’:

u = x’ / z’
v = y’ / z’

and scaling the normalized coord. with the img. resolution:

u *= image_width
v *= image_height