Depth camera

Discussion in 'Priority support' started by zohar.feldman, Jan 15, 2020.

  1. Hi,

    I am trying to figure out how to work with the depth camera in mujoco.
    Following the code in record.cpp, I am using mjr_readPixels as follows:
    mjr_readPixels(rgb, depth, viewport, &con_);
    In the example in record.cpp I see that the depth is later transformed like so
    (unsignedchar)((1.0f-depth[r*W+c])*255.0f)
    which implies that the returned depth is in [0,1]?

    Could you please reply what do the depth values actually represent?
     
    Last edited: Jan 28, 2020
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    This function simply calls the standard OpenGL function:

    glReadPixels(left, bottom, width, height, GL_DEPTH_COMPONENT, GL_FLOAT, depth_buffer);

    The result contains real-valued numbers between 0 and 1, which are normalized distances away from the camera... check the OpenGL documentation for details. The formula used in record.cpp simply inverts the depth image and scales to the range (0-255) for rendering as RGB.