一个ARWorldMap
具有rawFeaturePoints
,它是ARPointCloud
类型的点云
有谁知道如何像下面的视频中那样可视化此点云;
https://m.youtube.com/watch?v=Pb4uv4FSWKI
这怎么实现?
答案 0 :(得分:0)
正如您正确地说的那样,这可以使用rawFeaturePoints
实例属性来实现,该属性表示在相机图像中检测到的显着特征。
var rawFeaturePoints: ARPointCloud? { get }
OR
sceneView.session.currentFrame?.rawFeaturePoints
这是 Josh Robbins 在GitHub上写的CODE的摘录。
func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
guard let currentFrame = self.augmentedRealitySession.currentFrame,
let featurePointsArray = currentFrame.rawFeaturePoints?.points else { return }
visualizeFeaturePointsIn(featurePointsArray)
}
func visualizeFeaturePointsIn(_ featurePointsArray: [vector_float3]) {
self.augmentedRealityView.scene.rootNode.enumerateChildNodes { (featurePoint, _) in
featurePoint.geometry = nil
featurePoint.removeFromParentNode()
}
DispatchQueue.main.async {
self.rawFeaturesLabel.text = self.Feature_Label_Prefix + String(featurePointsArray.count)
}
featurePointsArray.forEach { (pointLocation) in
let clone = sphereNode.clone()
clone.position = SCNVector3(pointLocation.x, pointLocation.y, pointLocation.z)
self.augmentedRealityView.scene.rootNode.addChildNode(clone)
}
}