如何从内部和外部参数获取和使用单应性来获得图像的鸟瞰图?它可以用于投资回报率吗?

问题描述 投票:0回答:0

我有一张从高速公路 CARLA 中模拟的车辆拍摄的图像,我想鸟瞰这张图像,其中我感兴趣的飞机是公路飞机。我正在测试的图像在这里 View from vehicle

我知道内部参数和外部参数。内在函数仅来自 CARLA,矩阵如下所示:

intrinsic = [[1236. 0.    512.]
             [0.    1236. 256.]
             [0.    0.    1.]]

使用以下 paper 中的消失点方法估计外部因素。此外,论文中使用的框架约定与我使用的相同,如下所示。

Frame convention used

外部参数是

roll = 0
pitch = -5.0202
yaw = 4.3160
height = -1.3
,其中旋转以度为单位描述,平移以米为单位描述。翻译wrt。世界坐标系仅在 Y 轴方向移动。

论文中描述了我到目前为止所尝试的内容:

IPM from paper

但是我对

a_x, a_z
b_x, b_z
以及它们应该是什么感到非常困惑。对我来说,如何将这种单应性应用于图像并不完全清楚。

因此我也尝试使用这个answer中描述的方法,但没有用。我在 cv2.warpPerspective() 中使用了通过此方法发现的单应性结果:

Image after transformation

以下列方式应用外部参数以获得单应性。

旋转:

def rotation_world_to_cam(roll, pitch, yaw):
    R_r = np.array([[np.cos(roll),  np.sin(roll), 0],
                    [-np.sin(roll), np.cos(roll), 0],
                    [0,             0,            1]])

    R_p = np.array([[1, 0,              0            ],
                    [0, np.cos(pitch),  np.sin(pitch)],
                    [0, -np.sin(pitch), np.cos(pitch)]])

    R_y = np.array([[np.cos(yaw), 0, -np.sin(yaw)],
                    [0,           1, 0           ],
                    [np.sin(yaw), 0, np.cos(yaw)]])
    R_CW = R_r @ R_p @ R_y
    return R_CW

翻译:

def translation_world_to_cam(height):
   t_CW = np.array([0, height, 0])
   return t_CW

单应:

  def homography_world_to_camera(R_CW, t_CW):
    T = np.array([R_CW[:,0], R_CW[:,2], t_CW]).T
    H = self.intrinsic_matrix @ T
    return H

最后,我如何将它应用到图像的 ROI 上?

opencv camera-calibration homography
© www.soinside.com 2019 - 2024. All rights reserved.