How to reset or restart the ARCore session?

Mikiko Jane :

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

Andy :

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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=70871&siteId=1