Example #1
0
        public void UpdateNDKConfigWithUnityConfig(IntPtr configHandle, ARConfigBase arConfig)
        {
            NDKAPI.HwArConfig_setArType(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetARType());
            NDKAPI.HwArConfig_setCameraLensFacing(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetCameraLensFacing());
            NDKAPI.HwArConfig_setLightEstimationMode(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetLightingMode());
            NDKAPI.HwArConfig_setPlaneFindingMode(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetPlaneFindingMode());
            NDKAPI.HwArConfig_setUpdateMode(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetUpdateMode());
            NDKAPI.HwArConfig_setImageInputMode(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetImageInputMode());

            //this interface only support by HUAWEI_AR_ENGINE
            if (AREnginesSelector.Instance.GetCreatedEngine() == AREnginesType.HUAWEI_AR_ENGINE)
            {
                NDKAPI.HwArConfig_setPowerMode(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetPowerMode());
                NDKAPI.HwArConfig_setFocusMode(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetFocusMode());
                NDKAPI.HwArConfig_setEnableItem(m_ndkSession.SessionHandle, configHandle, arConfig.GetConfigEnableItem());
                NDKAPI.HwArConfig_setSemanticMode(m_ndkSession.SessionHandle, configHandle, arConfig.GetConfigSemanticMode());
            }

            //the following code is used to forward compatable
            if ((arConfig.GetARType() & (int)NDKARType.HAND_AR) != 0)
            {
                NDKAPI.HwArConfig_setHandFindingMode(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetHandFindingMode());
            }

            if (arConfig.GetAugImgDataBaseHandle() != null)
            {
                byte[] RawData = arConfig.GetAugImgDataBaseHandle().GetRawData();
                IntPtr AugImgDatabaseHandle = m_ndkSession.AugmentedImageDatabaseAdapter.CreateAugImgDatabaseFromBytes(RawData);
                NDKAPI.HwArConfig_setAugmentedImageDatabase(m_ndkSession.SessionHandle, configHandle, AugImgDatabaseHandle);
            }
        }
Example #2
0
        public void UpdateUnityConfigWithNDKConfig(IntPtr configHandle, ARConfigBase arconfig)
        {
            int ret = 0;

            NDKAPI.HwArConfig_getCameraLensFacing(m_ndkSession.SessionHandle, configHandle, ref ret);
            arconfig.SetCameraLensFacing((ARConfigCameraLensFacing)ret);
            AREnginesType aREnginesType = AREnginesSelector.Instance.GetCreatedEngine();

            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);

            //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);

                ulong enableItem = 0;
                NDKAPI.HwArConfig_getEnableItem(m_ndkSession.SessionHandle, configHandle, ref enableItem);

                enableItem           = 0;
                arconfig.EnableDepth = Convert.ToBoolean(enableItem & ARConfigBase.EnableItem_Depth);
                arconfig.EnableMask  = Convert.ToBoolean(enableItem & ARConfigBase.EnableItem_Mask);
            }
        }
Example #3
0
 public void Config(ARConfigBase config)
 {
     if (ARSessionStatus.PAUSED != Instance.SessionStatus &&
         ARSessionStatus.INIT != Instance.SessionStatus)
     {
         ARDebug.LogWarning("config when session is not init or paused, ignore it");
     }
     Instance.m_ndkSession.SessionAdapter.Config(config);
 }
Example #4
0
        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();
        }
Example #5
0
        public void Config(ARConfigBase unityConfig)
        {
            //ARDebug.LogInfo("native config begin" + unityConfig.ToString());
            IntPtr configHandle = m_ndkSession.ConfigBaseAdapter.Create();

            m_ndkSession.ConfigBaseAdapter.UpdateNDKConfigWithUnityConfig(configHandle, unityConfig);
            NDKARStatus status = NDKAPI.HwArSession_configure(m_ndkSession.SessionHandle, configHandle);

            ARDebug.LogInfo("native config end with value:{0}", status);
            m_ndkSession.ConfigBaseAdapter.UpdateUnityConfigWithNDKConfig(configHandle, unityConfig);
            m_ndkSession.ConfigBaseAdapter.Destroy(configHandle);
            ARExceptionAdapter.ExtractException(status);
        }
Example #6
0
 public bool IsSupported(ARConfigBase unityConfig)
 {
     return(true);
 }