我已经为脚创建了 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 …Run Code Online (Sandbox Code Playgroud)