As you rightly said, this could be achieved using rawFeaturePoints
instance property, what represents notable features detected in the camera image.
var rawFeaturePoints: ARPointCloud? { get }
OR
sceneView.session.currentFrame?.rawFeaturePoints
Here's an extract of CODE written by Josh Robbins on a GitHub.
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)
}
}