ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • SPARSE4D 입력 값 분석 - T_global_inv,T_global
    openxlab 2024. 8. 11. 11:41

    입력 값을 직접 가지고 있는 Parameter를 이용해서 만들어 보자!

    T_global 변수는 lidar to global 함수 이다. 즉 lidar   값이 입력이고 출력은 global이라는 뜻이다.

    input_dict["T_global_inv"] = np.linalg.inv(input_dict["lidar2global"])
    input_dict["T_global"] = input_dict["lidar2global"]

    data['img_metas'][0]['T_global']
    array([[-4.81423770e-01,  8.74948283e-01,  5.19293351e-02,
             6.01008072e+02],
           [-8.76460242e-01, -4.80091652e-01, -3.64616085e-02,
             1.64699540e+03],
           [-6.97118144e-03, -6.30674826e-02,  9.97984917e-01,
             1.82329309e+00],
           [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
             1.00000000e+00]])

     

    data['img_metas'][0]['T_global_inv']
    array([[-4.81423770e-01, -8.76460242e-01, -6.97118144e-03,
             1.73287827e+03],
           [ 8.74948283e-01, -4.80091652e-01, -6.30674826e-02,
             2.64972753e+02],
           [ 5.19293351e-02, -3.64616085e-02,  9.97984917e-01,
             2.70225329e+01],
           [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
             1.00000000e+00]])

     

    np.linalg.inv(aa)
    array([[-4.81423770e-01, -8.76460242e-01, -6.97118144e-03,
             1.73287827e+03],
           [ 8.74948283e-01, -4.80091652e-01, -6.30674826e-02,
             2.64972753e+02],
           [ 5.19293351e-02, -3.64616085e-02,  9.97984917e-01,
             2.70225329e+01],
           [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
             1.00000000e+00]])

     

    기존에 sensor to global  값과 역행렬 값을 가지고 있음을 확인 할 수 있다.

     

    이게 내가 좀 이해하기 힘든 부분인데 왜 이미지 사용하는데 라이다 정보를 가지고 있는지 모르겠다.

     

    이렇게 행렬을 가져가면 카메라 6개만 가지고 어떻게 행렬을 가져가나.

     

    즉 lidar to image  변환 행렬인것을 알 수 있다.

     

    수식으로 나타내면 기본 구조는 아래와 같고

    결국 아래와 같은 구조를 가진다.

     

     

     

    이론을 공부했으니 nuscene에 있는 자료를 기반으로 계산을 해보자!

     

    아래 처럼 같은 값을 얻을 수 있다. 

     

    lidar to image에 대한  matrix로 global to ego , ego to lidar로 

    nusc = NuScenes(version='v1.0-mini', dataroot='/data/sets/nuscenes', verbose=True)
    scene = nusc.scene[1]  # Adjust the scene index as needed
    current_sample_token = scene['first_sample_token']
    # 샘플 로드
    sample = nusc.get('sample', current_sample_token)
    
    lidar_data = nusc.get("sample_data", sample["data"]["LIDAR_TOP"])
    
    ego_pose_lidar = nusc.get("ego_pose", lidar_data["ego_pose_token"])
    
    lidar_calib = nusc.get("calibrated_sensor", lidar_data["calibrated_sensor_token"])
    
    # 카메라 캘리브레이션 정보에서 변환 행렬 계산
    lidar_translation = np.array(lidar_calib['translation'])
    lidar_rotation = Quaternion(lidar_calib['rotation']).rotation_matrix
    
    # Ego pose 정보에서 변환 행렬 계산
    ego_translation_lidar = np.array(ego_pose_lidar['translation'])
    ego_rotation_lidar = Quaternion(ego_pose_lidar['rotation']).rotation_matrix
        
    T_ego_lidar = np.eye(4)
    T_ego_lidar[:3, :3] = lidar_rotation
    T_ego_lidar[:3, 3] = lidar_translation
    
    
    T_global_ego_lidar = np.eye(4)
    T_global_ego_lidar[:3, :3] = ego_rotation_lidar
    T_global_ego_lidar[:3, 3] = ego_translation_lidar
    
    T_global_cam = T_global_ego_lidar @ T_ego_lidar
    T_global_cam_inv = np.linalg.inv(T_global_cam)
    
    T_global_cam
    array([[-4.81423770e-01,  8.74948283e-01,  5.19293351e-02,
             6.01008072e+02],
           [-8.76460242e-01, -4.80091652e-01, -3.64616085e-02,
             1.64699540e+03],
           [-6.97118144e-03, -6.30674826e-02,  9.97984917e-01,
             1.82329309e+00],
           [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
             1.00000000e+00]])
             
    T_global_cam_inv
    array([[-4.81423770e-01, -8.76460242e-01, -6.97118144e-03,
             1.73287827e+03],
           [ 8.74948283e-01, -4.80091652e-01, -6.30674826e-02,
             2.64972753e+02],
           [ 5.19293351e-02, -3.64616085e-02,  9.97984917e-01,
             2.70225329e+01],
           [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
             1.00000000e+00]])
    반응형
Designed by Tistory.