urbste / OpenImuCameraCalibrator

Camera calibration tool
GNU Affero General Public License v3.0
197 stars 43 forks source link

use my gopro calibration file to generate ***.yaml for ORB_slam3 #42

Closed vvcatstar closed 1 month ago

vvcatstar commented 1 month ago

I use openicc to calibrate my gopro9 and I get the calibration files: cam_imu_calib_result_GX010022.json and cam_calib_GX010020_fi_2.json, how to convert the calibration data to ***.yaml(slam configfile) to run orbslam3. I think the key parameter is Tbc: !!opencv-matrix data and camera intrinsic. Here is my calibration data. cam_calib_GX010020_fi_2.json cam_imu_calib_result_GX010022.json The target yaml file like this: image gopro9_maxlens_fisheye_setting.json Thanks.

urbste commented 1 month ago

In your cam_imu_calibresult*.json file you can find the two estimates quantities representing the camera to imu transformation as a quaternion and a translation vector. You can use those to get the camera to imu 4x4 matrix for ORB-SLAM3. Eg like this:

from scipy.spatial.transform import Rotation as R
import json, numpy as np

with open('cam_imu_calib_result_GX010022.json', "r") as f:
    data = json.load(f)
    q_cam_to_imu = [data["q_i_c"]["x"], data["q_i_c"]["y"], data["q_i_c"]["z"], data["q_i_c"]["w"]]
    t_cam_to_imu = [data["t_i_c"]["x"], data["t_i_c"]["y"], data["t_i_c"]["z"]]

    T_cam_to_imu = np.eye(4)
    T_cam_to_imu[:3, :3] = R.from_quat(q_cam_to_imu).as_matrix()
    T_cam_to_imu[:3, 3] = t_cam_to_imu

    print(T_cam_to_imu)