Rebuilt a real environment in MuJOCo: Setting the intrinsic and extrinsic camera matrix #2253
Replies: 4 comments
-
Re camera convention, this is well documented, so I don't think you searched very hard. MuJoCo uses right-handed frames and the X and Y axis point right and up in the image space, so the camera looks in the negative Z direction. Regarding instrisics, there is some documentation here, but I think you might need to look at the code for more information. For example the camprojection sensor's implementation is here |
Beta Was this translation helpful? Give feedback.
-
Hi @KieDani, have you solved your problem? I experienced the same case as you. After the camera intrinsic parameters are set, the rendered image can not be achieved any more. There pops an error: XML Error: Schema violation: unrecognized attribute: 'focalpixel'. I am using the same version of mujoco as you. And I followed the official document, While when the camera intrinsic parameters is not set, it works well. There is nothing I can find related to setting the camera intrinsic on the internet. @yuvaltassa Do you maybe have any suggestion on this point? |
Beta Was this translation helpful? Give feedback.
-
Given fx, fy, c, u, r (calculated as in my example above), I now set the camera stuff in the xml as
I obtain the intrinsic and extrinsic camera matrices from the mujoco model as
I hope this is enough to help you. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply! I fixed it. And my problem was still the version mismatch |
Beta Was this translation helpful? Give feedback.
-
Intro
Hi!
I am a researcher at University of Augsburg, I use MuJoCo for my research on computer vision for automatic sport's video analysis. I am currently working with table tennis images. Using some known 3D points on the image, I did successfully calibrate a real camera and obtained the intrinsic and extrinsic camera matrix. Now, I want to rebuild the setup environment in MuJoCo, but I am struggling to set the camera matrix correctly. So my question is: How to set up the MuJoCo camera to rebuild an environment with given intrinsic and extrinsic camera matrices?
My setup
I am using the Python API of MuJoCo. Version 3.2.3.
My question
Currently, MuJoCo only renders a black screen, which is probably because the camera points into the wrong direction. How do I have to set up the MuJoCo environment, such that the scene is correctly rendered? The image dimensions, the intrinsic matrix and the extrinsic matrix are given.
I am especially not sure how to set up the camera intrinsics (focal, resolution, sensorsize). Moreover, I am unsure about the conventions for the sign of the forward vector.
I already checked that the camera matrices correctly map the table points to the corresponding locations in the image plain. However, it seems that MuJoCo uses some different conventions that are not obvious to me.
Thank you for your help and clarifications! I hope this thread can lead to a summary of the camera conventions used in MuJoCo.
Minimal model and/or code that explain my question
This is the main function. I want to use the given camera matrices to set up the MuJoCo environment. I added multiple prints to ensure that the parameters are set correctly. I am not sure about the sign of the forward vector (but I cannot set it directly).
This code is used as sanity check to ensure that the camera matrices transform the table points correctly to image coordinates:
Here I define the intrinsic and extrinsic matrix. Importantly, fx and fy differ since I am working with real cameras. In my case, both fx and fy are positive. Is this a problem in MuJoCo?
The output of the print statements is as follows. Please note that
renderer.scene.camera[0].pos
gives unexpected values. Moreover I am not sure if the sign ofrenderer.scene.camera[0].forward
is correct.I attached the created images:
The rendered image is simply black. Probably due to facing the wrong direction or because of a severe mistake in setting the camera intrinsics.
My sanity checks show that the 3D table points are correctly transformed into image coordinates. So the camera matrices have to be correct. I am thus probably either using a wrong camera convention or I make a mistake in the xml.
Confirmations
Beta Was this translation helpful? Give feedback.
All reactions