0

An ARWorldMap has rawFeaturePoints, which is a pointcloud of type ARPointCloud

Does anyone know how to go about visualising this pointcloud much like in the following video;

https://m.youtube.com/watch?v=Pb4uv4FSWKI

How could this be achieved?

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Geoff H
  • 3,107
  • 1
  • 28
  • 53

1 Answers1

0

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)
    }
}
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220