我使用来自Intel Real Sense相机的彩色和深度图像生成点 Cloud .

使用 pyRealSense 库捕获图像 .

要将深度图像转换为 Cloud ,我使用以下基于 numpy 的函数:

def point_cloud(depth, cx=320.0, cy=240.0, fx=463.889, fy=463.889):
    """Transform a depth image into a point cloud with one point for each
    pixel in the image, using the camera transform for a camera
    centred at cx, cy with field of view fx, fy.

    depth is a 2-D ndarray with shape (rows, cols) containing
    depths from 1 to 254 inclusive. The result is a 3-D array with
    shape (rows, cols, 3). Pixels with invalid depth in the input have
    NaN for the z-coordinate in the result.

    My Changes:
        * Author had divided depth by 256 to normalize, I hadn't done that so I removed it.
        * Output coordinates are in units of 1m. There is a factor of 500 applied at image capture.
        * Author had returned a 3 * 480 * 640 np array. I changed to 3 flat arrays
    """
    rows, cols = depth.shape
    print fx, fy, cx, cy
    c, r = np.meshgrid(np.arange(cols), np.arange(rows), sparse=True)
    valid = (depth >= 0) & (depth <= 255)
    z = np.where(valid, depth, np.nan)
    x = np.where(valid, z * (c - cx) / fx, 0)
    y = np.where(valid, z * (r - cy) / fy, 0)
    return x.flatten(), y.flatten(), z.flatten()

这是一张显示我正在谈论的山脊的图像:

Ridges on a smooth surface

图像是坐在光滑的 table 上的物体 .
我看不出那些山脊会存在的原因,在那个区域没有等于零的深度值 .

这仅仅是 xy 的输入是整数这一事实的遗产吗?