Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reset or restart the ARCore session?

I need to reset/restart the ARCore session. In ARKit, I just have to create a new configuration and execute the RunWithConfigAndOptions method, but I can't find any information on how to do this in ARCore. The following is the code I use in Unity for ARKit:

ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
config.planeDetection = UnityARPlaneDetection.Horizontal;
config.alignment = UnityARAlignment.UnityARAlignmentGravity;
config.enableLightEstimation = true;  

UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(config, 
                                                                                    UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | 
                                                                                    UnityARSessionRunOption.ARSessionRunOptionResetTracking);

I'm working in Unity, but I guess any information will be useful.

Thanks

like image 442
Mikiko Jane Avatar asked Oct 16 '22 11:10

Mikiko Jane


1 Answers

Try DestroyImmediate(session) or Destroy(session). One of them may work.

ARCoreSession session = goARCoreDevice.GetComponent<ARCoreSession>();
ARCoreSessionConfig myConfig = session.SessionConfig;

DestroyImmediate(session);
// Destroy(session);

yield return null;

session = goARCoreDevice.AddComponent<ARCoreSession>();
session.SessionConfig = myConfig;
session.enabled = true;

Hope this helps.

like image 144
Andy Jazz Avatar answered Nov 01 '22 12:11

Andy Jazz