【问题标题】:Converting Kinect depth to png (python)将 Kinect 深度转换为 png (python)
【发布时间】:2016-09-08 08:58:45
【问题描述】:

我尝试验证分段算法,因此我需要一些好的数据。我想使用 NYU Depth V2 数据集 (http://cs.nyu.edu/~silberman/datasets/nyu_depth_v2.html)。现在我想使用点云库 png2pcd 方法创建一些 pcd 数据。但我需要彩色和深度图像。彩色的没问题,但深度以米为单位保存为浮点数。所以基本上像这样的值:

[[ 2.75201321 2.75206947 2.75221062 ...

是否有可能将这些值保存在 png 文件中,而不用在 python 中缩放?

【问题讨论】:

    标签: python png point-cloud-library depth


    【解决方案1】:

    如果您询问提取 1449 个标记数据集的 NYUv2 子集,以下转换将起作用。我不确定原始深度值,因为我也有类似的问题,但我的深度值范围为 0-2047。您知道将其保存为 .png 格式的方法吗?

        for i, (image, depth) in enumerate(zip(f['images'], f['depths'])):
        print("SHAPE::", np.shape(image), np.shape(depth), np.max(depth),np.min(depth))
        ra_image = image.transpose(2, 1, 0)
        ra_depth = depth.transpose(1, 0)
        re_depth = (ra_depth/np.max(ra_depth))*255.0
        print("AFTER--", np.shape(image), np.shape(depth), np.max(re_depth), np.min(re_depth))
        image_pil = Image.fromarray(np.uint8(ra_image))
        depth_pil = Image.fromarray(np.uint8(re_depth))
        image_name = os.path.join("data", "nyu_datasets", "%05d.jpg" % (i))
        # image_pil.save(image_name)
        depth_name = os.path.join("data", "nyu_datasets", "%05d.png" % (i))
        # depth_pil.save(depth_name)
    

    【讨论】:

      【解决方案2】:

      是的。在 OpenCV python 中:

      depthMap = numpy.array([your depth value array])
      cv2.imwrite('xxx.png', depthMap)
      

      【讨论】:

        猜你喜欢
        • 2013-07-30
        • 1970-01-01
        • 1970-01-01
        • 2015-06-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多