Intel RealSense D415 get intrinsic parameters using the API (pyrealsense2)
I’m developing my custom calibration application using python and pyrealsense2 and I would like to initialize the intrinsic parameters using the factory calibration of the device.
But I have not found a direct way to obtain the current intrinsic parameters of the camera of the left and right cameras.
The ones by the IR stream with the format Y8 are rectified and the distortion coefficients are set to 0.
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.infrared,1 ,1920, 1080, rs.format.y8,15)
config.enable_stream(rs.stream.infrared,2 ,1920, 1080, rs.format.y8,15)
cfg = pipeline.start(config)
profile = cfg.get_stream(rs.stream.infrared,1) # Fetch stream profile for depth stream
intr = profile.as_video_stream_profile().get_intrinsics()
if I use the Y16 format does not return any parameters at all.
So far the only working option I have found is to call the CustomRW application using the following command Intel.Realsense.CustomRW.exe -r. But I’m sure there is a more straightforward way using the real sense API.
Is there a way to obtain the factory intrinsic parameters of the device using the RealSense API?
Hi Oriol Vila You are correct that the camera intrinsics can be retrieved in Python with the get_intrinsics() instruction.
On the majority of RealSense 400 Series camera models all coefficients are deliberately set to zero (except for RGB on the D455 model, which is non-zero). The reason for this is provided at the link below.
The Y16 infrared format does not have retrievable intrinsics. It is unrectified because it is used for camera calibration.
You can list all available intrinsic and extrinsic parameters for a camera using the RealSense SDK's 'rs-enumerate-devices' tool by inputting the command below to launch the tool in calibration in calibration information mode.
The parameters listed by rs-enumerate-devices will be the values currently listed in the camera's calibration table, which means that they will not be the original factory-new parameters if the camera has been re-calibrated since purchase. If you need the original factory calibration then you can reset the camera to them in the RealSense Viewer tool using the instructions at the link below.
As you said, the coefficients are set to zero for the stereo matching. Therefore when I get the intrinsic parameters of the rectified infrared stream they are all zero.
The problem is that I want to do camera calibration and I'm working with the Y16 format. In this case, the distortion coefficients are required for generating the XML calibration file. And by default, they have a factory value which I want to know.
After connecting an Intel camera I can reset the gold factory calibration settings with
And If I then read the calibration parameters using
And then I get the non-zero distortion coefficients I need in order to do a better recalibration.
Is there a way I can read all these parameters using the pyrealsense2/realsense API without having to execute the external Intel.Realsense.CustomRW.exe application?
Why is it not possible to retrieve the Y16 infrared format intrinsics using the .get_intrinsics() function?
So far I have been able to calibrate D415 devices only using pyrealsense2 and OpenCV, but I would like to read the default calibrations parameters including the distortion coefficients from the Y16 format.
rs-enumerate-devices -c does not return me with the Y16 intrinsic coefficients that I need.
I hope this time I have explained myself better.
If the coefficients are retrieved through SDK instructions instead of with the external CustomRW tool then they will be the zeroed version of the values rather than the raw originals.
In a old case at the link below, a RealSense user identified the intrinsics for the Y16 stream using CustomRW by looking at the intrinsics for 1280x800 resolution.
As a RealSense team member in the above-linked discussion confirms, intrinsics for Y16 cannot be listed using sensor querying tools created with RealSense SDK programming language instructions, such as rs-sensor-control, because the SDK's API does not have a mechanism for doing so.
Please sign in to leave a comment.