/// <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();
            }
        }
예제 #2
0
 public void SetPikkartCamera(PikkartARCamera camera)
 {
     _pikk_camera = camera;
 }