Computer vision 将深度图像与RGB图像对齐

Computer vision 将深度图像与RGB图像对齐,computer-vision,kinect,openni,depth,openkinect,Computer Vision,Kinect,Openni,Depth,Openkinect,我试图使用Kinect通过Python和libfreenect捕获的图像生成点云,但我无法将深度数据与Kinect获取的RGB数据对齐 我申请了,但这两张图片被远远地移开了,我的代码是否有问题: 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

我试图使用Kinect通过Python和libfreenect捕获的图像生成点云,但我无法将深度数据与Kinect获取的RGB数据对齐

我申请了,但这两张图片被远远地移开了,我的代码是否有问题:

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

我做错什么了吗?感谢您的帮助首先,检查您的校准编号。旋转矩阵近似为恒等式,假设校准帧为公制,则平移向量表示第二个摄影机的侧面偏移2厘米,深度偏移1厘米。这与您的设置大致相符吗?如果不是,您可能使用了错误的缩放比例(可能使用了错误的数字作为校准目标的特征尺寸-棋盘?)

您的代码看起来正确-您正在以已知深度重新投影深度摄影机的一个像素,然后将其投影回第二个摄影机以获得相应的rgb值

我想检查一下你的坐标变换是否正确。IIRC,OpenCV将其生成为[R | t],但您将其用作[R |-t],这看起来很可疑。也许你想用它的倒数,也就是[R'|-R'*t],我用撇号来表示转置