toinsson / pyrealsense

Cross-platform ctypes/Cython wrapper to the librealsense library (v1.x)
http://pyrealsense.readthedocs.io
Apache License 2.0
121 stars 46 forks source link

problem with loading calibration data by pyrealsense #78

Closed robinloujun closed 6 years ago

robinloujun commented 6 years ago
Required Info
Camera Model SR300
Firmware Version
Operating System & Version Ubuntu 16.04 (Kernel 4.13)
python version python 2.7.12
librealsense version v1.12.1
pyrealsense version v2.2

Hello,

I am now working with pyrealsense to get the rgb and depth images with a SR300. As they are from two different cameras, there is alignment (s. following image) between them. I think it could be "deleted" after the calibration.

I've tried to calibrate the camera with 2 methods. First is with the ROS package camera_calibration, and the result is a camera.yaml, which could be converted to other format. The other is to use the OpenCV to do the calibration, which could be found here, and the result here is a NumPy document called 'calibration_data.npz' (like many other exsamples like this)

The problem is I cannot find how to load the calibration data by pyrealsense. Could you simply explain how I can load one of those data? Thanks a lot in advance!

question

[Complement]

I found that in the setup of offline.py there are functions for saving & loading the intrinsics of color & depth cameras from yaml. But I don't know how to use it since the test_offline.py doesn't call the functions. And I wonder if the online usage is also based on the same principle.

[Complement]

Now I know that it is not a problem with pyrealsense because the intrinsics of RealSense SR300 is fixed. But We can use OpenCV to calibrate the frames. These are the codes for it and I think this issue could be closed.

calibrationdata = np.load('calibration_data.npz')
mtx = calibration['mtx']
dist = calibration['dist']
calibrationdata.close()
color_undistort = cv2.undistort(color, mtx, dist, None)