public void LaunchWebcam(WebCamManager webcam)
 {
     markerFoundPtr     = Marshal.AllocHGlobal(512);
     viewMatrixData     = new HandledArray <float>(Constants.MATRIX_4X4_ARRAY_SIZE);
     trackedMarkersData = new HandledArray <int>(30);
     _webcam            = webcam;
     _webcam.StartWebcam(false);
     StartCoroutine(CameraLoop());
 }
        /// <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();
            }
        }