これはあいまいな質問かもしれませんが、人々が ARKit 3 の新しい ARKit ピープル オクルージョン テクノロジーをどのように使用して、人々を背景から効果的に「分離」し、ある種のフィルタリングを「人」(こちらを参照)。
Apple が提供するソース コードとドキュメントを見るとsegmentationBuffer
、ARFrame から を取得できることがわかります。
func session(_ session: ARSession, didUpdate frame: ARFrame) {
let image = frame.capturedImage
if let segementationBuffer = frame.segmentationBuffer {
// Get the segmentation's width
let segmentedWidth = CVPixelBufferGetWidth(segementationBuffer)
// Create the mask from that pixel buffer.
let sementationMaskImage = CIImage(cvPixelBuffer: segementationBuffer, options: [:])
// Smooth edges to create an alpha matte, then upscale it to the RGB resolution.
let alphaUpscaleFactor = Float(CVPixelBufferGetWidth(image)) / Float(segmentedWidth)
let alphaMatte = sementationMaskImage.clampedToExtent()
.applyingFilter("CIGaussianBlur", parameters: ["inputRadius": 2.0)
.cropped(to: sementationMaskImage.extent)
.applyingFilter("CIBicubicScaleTransform", parameters: ["inputScale": alphaUpscaleFactor])
// Unknown...
}
}
「不明」セクションでは、元のカメラ フィードの上に新しい「ぼやけた」人物をレンダリングする方法を決定しようとしています。ARView には手動で更新する方法がないため、元のカメラ フィードの「上」に新しい CIImage を描画する方法はないようです。