首页 > 解决方案 > iOS14 ARDepthData 的分辨率是多少?

问题描述

我正在尝试可视化由ARSession和捕获的深度数据ARCamera。我看到深度很好,除了平面物体(如显示器)的边缘,我希望在渲染平面和背景之间有更清晰的过渡。

我观察到的是物体边缘的“磨损”,深度值发生了显着变化。(创建自由浮动线,如下图所示)。我想删除自由浮动线。

这让我问:

ARDepthData 的“真实”分辨率是多少(值的哪一部分可以安全地作为噪声丢弃)?

使用 ARDepthData 时如何避免舍入错误?

open class ARDepthData : NSObject {
    /*  A pixel buffer that contains per-pixel depth data (in meters). */
    unowned(unsafe) open var depthMap: CVPixelBuffer { get }
}

这是我尝试剪辑值的方式,但这会扭曲图像其余部分的分辨率。

   const float2 samplePoint = float2(x, y); //0.0 - 1.0 range

    const float2 clippingMultiplier = float2(64, 64);
    const float2 clippedTextureCoordinate = (floor(texCoord * clippingMultiplier)) / clippingMultiplier; //attempt to clip fractional components

 // What are the appropriate sampling filter parameters to reduce the error like in the screenshot?
 constexpr sampler depthSampler(mip_filter::nearest, mag_filter::nearest, min_filter::nearest);

 const auto depth = depthMap.sample(depthSampler, clippedTextureCoordinate).r;
 //depth is used to calculate position

在此处输入图像描述

这是我从深度值中删除小数部分的尝试:

在此处输入图像描述

标签: shaderarkitmetalios14

解决方案


对于前置真深度相机,AVDepthData 的最大深度分辨率为w640 h480.

ARDepthData 似乎具有类似的低分辨率:

depth:       w256 h192
confidence:  w256 h192

推荐阅读