swiftarkitarworldmap

How to merge two separate ARWorldMaps into bigger one?


I have two ARWorldMaps captured onto two iOS devices and then sent to server. These maps have similar tracked areas but also have different ones. Both maps are stored on remote server. It should be noted that there's no multiuser experience in my AR app.

fileprivate func retrieveWorldMap() {

    let storedData = UserDefaults.standard

    if let data = storedData.data(forKey: "WorldMap") {
        
        if let unarchiver = try? NSKeyedUnarchiver.unarchivedObject(
                             ofClasses: [ARWorldMap.classForKeyedUnarchiver()],
                                  from: data),
            let worldMap = unarchiver as? ARWorldMap {

            config.initialWorldMap = worldMap
            sceneView.session.run(config, options: [])
        }
    }
}

How to merge two ARWorldMaps into bigger one, without help of a MultipeerConnectivity?


Solution

  • Combining 2 archived ARWorldMaps

    Merging two ARWorldMaps “blindly”, without using visual control with comparison algorithm, doesn't make sense. ARKit engineers suggested doing this only when you're running a new session that combines new detected points with a sparse point cloud from a saved session. Combining two adjacent ARWorldMaps “blindly” has no practical value, since the overall positioning accuracy of the point cloud will significantly decrease (which lead us to irreversible positioning errors of AR models), because the maps are combined without reference to a real-world environment.