首页 文章

将深度图像与RGB图像对齐

提问于
浏览
0

我正在尝试使用Kinect使用Python和libfreenect捕获的图像生成点 Cloud ,但我无法将深度数据与Kinect拍摄的RGB数据对齐 .

我应用了Nicolas Burrus's equation但两张图片变得更远,我的代码有问题:

cx_d = 3.3930780975300314e+02
cy_d = 2.4273913761751615e+02
fx_d = 5.9421434211923247e+02
fy_d = 5.9104053696870778e+02
fx_rgb = 5.2921508098293293e+02
fy_rgb = 5.2556393630057437e+02
cx_rgb = 3.2894272028759258e+02
cy_rgb = 2.6748068171871557e+02
RR = np.array([
    [0.999985794494467, -0.003429138557773, 0.00408066391266],
    [0.003420377768765,0.999991835033557, 0.002151948451469],
    [-0.004088009930192, -0.002137960469802, 0.999989358593300 ]
])
TT = np.array([ 1.9985242312092553e-02, -7.4423738761617583e-04,-1.0916736334336222e-02 ])

# uu, vv are indices in depth image
def depth_to_xyz_and_rgb(uu , vv):

    # get z value in meters
    pcz = depthLookUp[depths[vv , uu]]

    # compute x,y values in meters
    pcx = (uu - cx_d) * pcz / fx_d
    pcy = (vv - cy_d) * pcz / fy_d

    # apply extrinsic calibration
    P3D = np.array( [pcx , pcy , pcz] )
    P3Dp = np.dot(RR , P3D) - TT

    # rgb indexes that P3D should match
    uup = P3Dp[0] * fx_rgb / P3Dp[2] + cx_rgb
    vvp = P3Dp[1] * fy_rgb / P3Dp[2] + cy_rgb

    # return a point in point cloud and its corresponding color indices
    return P3D , uup , vvp

有什么我做错了吗?任何帮助表示赞赏

1 回答

  • 1

    首先,检查校准编号 . 您的旋转矩阵大致是标识,并且假设您的校准框架是公制,您的平移向量表示第二个摄像头距离侧面2厘米,深度位移1厘米 . 这大致符合您的设置吗?如果没有,您可能正在使用错误的缩放(可能使用错误的数字作为校准目标的特征尺寸 - 棋盘?) .

    您的代码看起来是正确的 - 您将深度相机的像素重新投影到已知深度,并将其投影回第二个相机以获得相应的rgb值 .

    有人认为我会检查你是否使用你的坐标转换正确的方向 . IIRC,OpenCV将其生成为[R | t],但你用它作为[R | -t],看起来很可疑 . 也许你的意思是使用它的逆,这将是[R'| -R'* t],我使用撇号来表示换位 .

相关问题