protected override void OnResume() { Log.Debug(TAG, "OnResume"); base.OnResume(); mDisplayRotationManager.RegisterDisplayListener(); Exception exception = null; message = null; if (mArSession == null) { try { if (!ArEngineAbilityCheck()) { Finish(); return; } mArSession = new ARSession(this); mArConfig = new ARFaceTrackingConfig(mArSession); mArConfig.SetPowerMode(ARConfigBase.PowerMode.PowerSaving); if (isOpenCameraOutside) { mArConfig.SetImageInputMode(ARConfigBase.ImageInputMode.ExternalInputAll); } mArSession.Configure(mArConfig); } catch (Exception capturedException) { exception = capturedException; SetMessageWhenError(capturedException); } if (message != null) { StopArSession(exception); return; } } try { mArSession.Resume(); } catch (ARCameraNotAvailableException e) { Toast.MakeText(this, "Camera open failed, please restart the app", ToastLength.Short).Show(); mArSession = null; return; } mDisplayRotationManager.RegisterDisplayListener(); SetCamera(); mFaceRenderManager.SetArSession(mArSession); mFaceRenderManager.SetOpenCameraOutsideFlag(isOpenCameraOutside); mFaceRenderManager.SetTextureId(textureId); glSurfaceView.OnResume(); }
public void UpdateUnityConfigWithNDKConfig(IntPtr configHandle, ARConfigBase arconfig) { int ret = 0; NDKAPI.HwArConfig_getCameraLensFacing(m_ndkSession.SessionHandle, configHandle, ref ret); arconfig.SetCameraLensFacing((ARConfigCameraLensFacing)ret); ARDebug.LogInfo("UpdateUnityConfigWithNDKConfig GetARType size {0}", arconfig.GetARType()); NDKAPI.HwArConfig_getLightEstimationMode(m_ndkSession.SessionHandle, configHandle, ref ret); arconfig.SetLightingMode((ARConfigLightingMode)ret); NDKAPI.HwArConfig_getPlaneFindingMode(m_ndkSession.SessionHandle, configHandle, ref ret); arconfig.SetPlaneFindingMode((ARConfigPlaneFindingMode)ret); NDKAPI.HwArConfig_getUpdateMode(m_ndkSession.SessionHandle, configHandle, ref ret); arconfig.SetUpdateMode((ARConfigUpdateMode)ret); NDKAPI.HwArConfig_getImageInputMode(m_ndkSession.SessionHandle, configHandle, ref ret); arconfig.SetImageInputMode(ret); //this interface only support by HUAWEI_AR_ENGINE if (AREnginesSelector.Instance.GetCreatedEngine() == AREnginesType.HUAWEI_AR_ENGINE) { NDKAPI.HwArConfig_getHandFindingMode(m_ndkSession.SessionHandle, configHandle, ref ret); arconfig.SetHandFindingMode((ARConfigHandFindingMode)ret); NDKAPI.HwArConfig_getPowerMode(m_ndkSession.SessionHandle, configHandle, ref ret); arconfig.SetPowerMode((ARConfigPowerMode)ret); NDKAPI.HwArConfig_getFocusMode(m_ndkSession.SessionHandle, configHandle, ref ret); arconfig.SetFocusMode((ARConfigFocusMode)ret); ulong enableItem = 0; NDKAPI.HwArConfig_getEnableItem(m_ndkSession.SessionHandle, configHandle, ref enableItem); arconfig.EnableDepth = Convert.ToBoolean(enableItem & ARConfigBase.EnableItem_Depth); arconfig.EnableMask = Convert.ToBoolean(enableItem & ARConfigBase.EnableItem_Mask); arconfig.EnableMesh = Convert.ToBoolean(enableItem & ARConfigBase.EnableItem_Mesh); arconfig.EnableHealth = Convert.ToBoolean(enableItem & ARConfigBase.EnableItem_Health); int enableSemanticMode = 0; NDKAPI.HwArConfig_getSemanticMode(m_ndkSession.SessionHandle, configHandle, ref enableSemanticMode); arconfig.SemanticPlaneMode = Convert.ToBoolean(enableItem & ARConfigBase.EnableSemanticPlaneMode); } }