# Camera matrix

Discussion in 'Visualization' started by dhiraj, Jul 8, 2018.

1. ### dhiraj

Hi,

I wanted to convert the image space pixel co-ordinate to 3D world in mujoco. I was trying to find camera intrinsic matrix for the camera body that I attached to the robot, but I couldn't find any information regarding this. I was trying to use the FOV defination to calculate the focal length and considering ideal camera, I was trying to calculate the intrinsic matrix. Is this the right way to do it or there is better way available ?

2. ### Shin Y

Same issue, I guess your approach might be the only way to implement it. Have you implement your solution ?

3. ### dhiraj

Hi Shin,

I used fov to calculate somekind of intrinsic matrix and it works.

4. ### Shin Y

Wow, cool! Could you specify some more details or some sample code? I know little about this field and feel difficult to implement it in the past few days. Many thanks !

5. ### dhiraj

this what I have written to get cordinate from image frame to 3D world .. camera is pointing downward and height represent its height from ground, its giving output in frame attached to camera
## for transformaing pixel co-ordinate to 3d world
class cam():
def __init__(self,height=1.5,rot = 0, fov=45.0):
self.height = height ## height of the camera from ground
self.rot = rot ## rotation of camera around base Y axis
self.fov = fov ## fov of camera in degrees

def d2_to_d3(self,x = 0, y = 0):
## x and y varies from -1 to 1
## return XYZ in the frame attach to camera link allined with base link
X = self.height * tan(theta_x)
Z = self.height