Hello ThangNguyen_BZ,
There are two approaches for multiple room scans. The approach I was using in this post is continuous scan, and you are experiencing problems with relocalization. To get more targeted help and increase the chances of finding a solution, it's a good idea to create a separate post dedicated to the relocalization and scanning issues you're facing. This way, other developers who have encountered similar problems can chime in and offer their insights.
Here are some suggestions from me to consider:
You said sometimes you can't scan. It'd be helpful to clarify if scanning works occasionally. If that's the case, please ensure you check if the worldMap is saved successfully after your first scan. You can do this by downloading the corresponding container to your app and right-clicking to select "Show Package Contents." This way, you can inspect the saved worldMap data and verify if it's being persisted correctly.
When you mentioned that you can't merge different scans, is there any error messages or specific error behavior you've encountered? Having additional information about the issue will aid in identifying the cause.
Assuming the worldMap is saved and loaded successfully, you might want to try setting the configuration without initializing a new RoomCaptureView.
configuration.initialWorldMap = worldMap
roomCaptureView?.captureSession.arSession.run(configuration, options: [.resetTracking])
Post
Replies
Boosts
Views
Activity
Hello ThangNguyen_BZ, Could you be more specific about the issue you are getting?
To use a custom ARSession, my modification to the sample code are in the first post.
Did you saved it as NSData using NSKeyedArchiver?
This problem is solved.
In the previous implementation, cancelScanning() is called when isScanning is false
@IBAction func saveScanning(_ sender: UIBarButtonItem) {
if isScanning { saveSession() } else { cancelScanning(sender) }
self.exportButton?.isEnabled = false
self.activityIndicator?.startAnimating()
}
The implementation of cancelScanning() dismiss the navigationController which cause the problem of initiating a new instance of the RoomCaptureViewController class when starting the next scanning session
@IBAction func cancelScanning(_ sender: UIBarButtonItem) {
navigationController?.dismiss(animated: true)
}
Solution:
Just call startSession() to start the next capture session with the same ARSession.
@IBAction func saveScanning(_ sender: UIBarButtonItem) {
if isScanning { saveSession() } else { startSession() }
self.exportButton?.isEnabled = false
self.activityIndicator?.startAnimating()
}