Example #1
0
        public void ChangeRecognitionOptions(RecognitionOptions recognitionOptions)
        {
            if (_recognitionRunning)
            {
                if (_currentRecognitionOptions.getStorage() != recognitionOptions.getStorage())
                {
                    if (recognitionOptions.getStorage() != RecognitionOptions.RecognitionStorage.LOCAL)
                    {
                        PikkartARCore.StartEffect();
                    }
                    else
                    {
                        PikkartARCore.StopEffect();
                    }

                    PikkartARCore.ChangeMode(recognitionOptions.getStorage() != RecognitionOptions.RecognitionStorage.LOCAL);
                }

                if (_currentRecognitionOptions.getMode() != recognitionOptions.getMode())
                {
                    if (recognitionOptions.getMode() != RecognitionOptions.RecognitionMode.TAP_TO_SCAN)
                    {
                        stopTimers();
                    }
                    else
                    {
                        scheduleTimers();
                    }
                }
            }

            _currentRecognitionOptions = recognitionOptions;
        }
Example #2
0
        /// <summary>
        /// Starts the native service recognition.
        /// </summary>
        /// <param name="recognitionOptions">Recognition options.</param>
        /// <param name="recognitionListener">Recognition listener(MainScript).</param>
        public void StartRecognition(RecognitionOptions recognitionOptions, IRecognitionListener recognitionListener)
        {
            StopRecognition();

            SyncMarkersWithFolder();

            _recognitionRunning = true;
            _active             = true;

            _currentRecognitionOptions = recognitionOptions;
            _recognitionListener       = recognitionListener;
            _dataProvider = new RecognitionDataProvider(recognitionOptions.getCloudInfo(), this, GetDeviceId());

#if !UNITY_EDITOR
            if (!LoadSavedCameraParams())
            {
                _dataProvider.ExecuteGetCameraParamFromServer(true);
            }
#endif

            PikkartARCore.ChangeMode(_currentRecognitionOptions.getStorage() != RecognitionOptions.RecognitionStorage.LOCAL);
            PikkartARCore.StartRecognition(_currentRecognitionOptions.getStorage() != RecognitionOptions.RecognitionStorage.LOCAL, false);

            PikkartARCore.StartEffect();

            _markerId = "";

            if (_currentRecognitionOptions.getMode() == RecognitionOptions.RecognitionMode.TAP_TO_SCAN)
            {
                scheduleTimers();
            }
        }
        protected void StartRecognition(RecognitionOptions recognitionOptions)
        {
#if UNITY_EDITOR
            if (!useWebcamOnEditor)
            {
                return;
            }
#endif
            _recognitionOptions = recognitionOptions;
            _recognitionManager.StartRecognition(recognitionOptions, _recognitionListener);
        }
 protected void ChangeRecognitionOptions(RecognitionOptions recognitionOptions)
 {
     _recognitionManager.ChangeRecognitionOptions(recognitionOptions);
 }
 protected void StartRecognition(RecognitionOptions recognitionOptions, IRecognitionListener recognitionListener)
 {
     SetRecognitionListener(recognitionListener);
     StartRecognition(recognitionOptions);
 }
        /// <summary>
        /// Init this instance. Initialize and start RecongnitionManager, PikkartCamera and NatCamManager.
        /// </summary>
        protected IEnumerator InitRecognition()
        {
            foreach (var device in WebCamTexture.devices)
            {
                Debug.Log("Name: " + device.name);
            }
            yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam));

            if (Application.HasUserAuthorization(UserAuthorization.WebCam))
            {
                Debug.Log("webcam found");
            }
            else
            {
#if UNITY_EDITOR
                if (EditorUtility.DisplayDialog("Camera error!",
                                                "You cannot use our SDK without a camera!\n" +
                                                "Please connect a camera and try again.", "Ok"))
                {
                    EditorApplication.isPlaying = false;
                }
#endif
                Debug.Log("webcam error no webcam");
                yield break;
            }

#if UNITY_EDITOR
            if (!useWebcamOnEditor)
            {
                yield break;
            }
#endif
            Screen.sleepTimeout = SleepTimeout.NeverSleep;

            foreach (CloudMarkerObject cloudMarker in _cloudMarkers)
            {
                cloudMarker.Init();
            }
            foreach (MarkerObject marker in _markerObjects)
            {
                marker.Init();
            }

            _camera = FindObjectOfType <PikkartARCamera>();

            _webcam = FindObjectOfType <WebCamManager>();

            if (_recognitionManager == null)
            {
                _recognitionManager = new RecognitionManager(this);
                _recognitionManager.LoadLocalMarkersOnStartup(true, _markerList, _discoverList);
            }
            else
            {
                PikkartARCore.SyncMarkersWithFolder();
            }

            _camera.SetRecognitionManager(_recognitionManager);

            _recognitionOptions = new RecognitionOptions(
                recognitionStorage,
                recognitionMode,
                new CloudRecognitionInfo(databases));

            if (_webcam.HasWebcam())
            {
                _camera.LaunchWebcam(_webcam);
            }
            else
            {
#if UNITY_EDITOR
                if (EditorUtility.DisplayDialog("Camera error!",
                                                "You cannot use our SDK without a camera!\n" +
                                                "Please connect a camera and try again.", "Ok"))
                {
                    EditorApplication.isPlaying = false;
                }
#endif
                Debug.Log("webcam error no webcam");
            }
#if UNITY_EDITOR
            if (_recognitionOptions.getMode() != RecognitionOptions.RecognitionMode.TAP_TO_SCAN)
            {
                if (FindObjectOfType <ScanButton>() != null)
                {
                    FindObjectOfType <ScanButton>().gameObject.SetActive(false);
                }
            }
#else
            if (FindObjectOfType <ScanButton>() != null)
            {
                FindObjectOfType <ScanButton>().gameObject.SetActive(false);
            }
#endif
            _camera.SetMarkers(ref _markerObjects, ref _cloudMarkers);

            _camera.SetSeeThroughDevice(isSeeThroughDevice, seeThroughFramePrediction);

            if (_recognitionListener != null)
            {
                _recognitionListener.OnPikkartARStartupComplete();
            }
        }