如何在实时跟踪中将 3D 对象包裹在检测到的对象周围

Sai*_*aif 5 image-recognition swift apple-vision arkit coreml

我已经为脚创建了 ML 模型作为 VNRecognizedObjectObservation 现在我能够成功地在实时跟踪中检测脚,问题是我无法将 3D 对象包裹或放置在脚上,因为我需要 3 个坐标来放置 AR 内容。

我使用下面的代码在视觉框架检测到我的脚后获取边界框

func drawVisionRequestResults(_ results: [Any]) {
        CATransaction.begin()
        CATransaction.setValue(kCFBooleanTrue, forKey: kCATransactionDisableActions)
        detectionOverlay.sublayers = nil // remove all the old recognized objects

        let obs = results.first
        let final = obs

        for observation in results where observation is VNRecognizedObjectObservation {
            guard let objectObservation = observation as? VNRecognizedObjectObservation else {
                continue
            }
            // Select only the label with the highest confidence.
            let topLabelObservation = objectObservation.labels[0]
            let objectBounds = VNImageRectForNormalizedRect(objectObservation.boundingBox, Int(bufferSize.width), Int(bufferSize.height))

            let shapeLayer = self.createRoundedRectLayerWithBounds(objectBounds)

            let textLayer = self.createTextSubLayerInBounds(objectBounds,
                                                            identifier: topLabelObservation.identifier,
                                                            confidence: topLabelObservation.confidence)
            shapeLayer.addSublayer(textLayer)
            detectionOverlay.addSublayer(shapeLayer)
            //   addModel(objectBounds)
            translateCoordinate(objectBounds)
        }
        self.updateLayerGeometry()
        CATransaction.commit()
    }
Run Code Online (Sandbox Code Playgroud)

但我在 objectBounds 变量中仅获得 x 、 y 高度和宽度的 2d 坐标...我需要知道 ARScene 空间中的 3d 坐标来放置我的 3d 对象...当我输入相同的值时,命中测试也不会返回任何坐标x和yi认为Arkit世界坐标和普通手机世界坐标存在某种关系

提前致谢