Camera matrix

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

  1. 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. Same issue, I guess your approach might be the only way to implement it. Have you implement your solution ?
  3. Hi Shin,

    Sorry for late reply.

    I used fov to calculate somekind of intrinsic matrix and it works.
  4. 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. 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
    fx = 1/tan(radians(self.fov/2.0))
    theta_x = radians(self.rot) + atan2(x,fx)
    X = self.height * tan(theta_x)
    Z = self.height
    fy = 1/tan(radians(self.fov/2.0))
    theta_y = atan2(y,fy)
    Y = tan(theta_y) * self.height / cos(theta_x)
    return X,Y,Z
  6. Cool ! I have been thinking about how to solve this without any constraints on camera. I think I would also add some restrictions to my camera. Many thanks !
  7. A small issue: why do you set the value of Z as self.height, which is a fixed value? If so, all the points should be in a plane and there is no difference between the result and original image . BTW, are the ranges of x and y determined by the size of your scene ?