public void Open()
        {
            if (IsScanning)
            {
                return;
            }

            //Turn this on right away to avoid a second scanner from starting right away.
            IsScanning = true;
            m_Source   = m_MarkerController.CameraSource;
            m_Source.RequestedHeight = 720;
            m_Source.RequestedWidth  = 1280;
            m_Source.Run();
            m_ScanUI.Open(m_Source.Texture);
            m_BarcodeDecoder = new QRBarcodeDecoder();
            _ = Scan();

            if (m_ResultHandler != null)
            {
                StopCoroutine(m_ResultHandler);
            }

            m_ResultHandler = ResultHandler();
            StartCoroutine(m_ResultHandler);
        }
 public void Close()
 {
     Debug.Log($"[ARInstructionUI] Closing barcode scanner: IsScanning {IsScanning}");
     if (!IsScanning)
     {
         return;
     }
     IsScanning = false;
     m_ScanUI.Close();
     m_MarkerController.CameraSource?.Stop();
     m_BarcodeDecoder?.Dispose();
     m_BarcodeDecoder = null;
     m_Source         = null;
     m_MarkerController.BarcodeScannerExited();
 }
    public void StopDecoding()
    {
        if (_webCam != null)
        {
            _webCam.Stop();
        }

        _webCam  = null;
        _decoder = null;

        if (_cancel != null)
        {
            _cancel.IsPending = true;
            _cancel           = null;
        }
    }
    void Start()
    {
        menu.GetComponent <Canvas>().enabled           = false;
        messageOverlay.GetComponent <Canvas>().enabled = false;
        decrypt.GetComponent <Button>().onClick.AddListener(Submit);
        exitMessage.GetComponent <Button>().onClick.AddListener(RemoveMessageBox);

        qr_decoder = Barcode.GetDecoder();

        WebCamDevice[] deviceList = WebCamTexture.devices;
        if (deviceList.Length > 0)
        {
            webcam = new WebCamTexture(deviceList[0].name);
            GetComponent <Renderer>().material.mainTexture = webcam;
            webcam.Play();
        }
    }
    public IEnumerator StartDecoding(WebCamTexture webCam)
    {
        _webCam = webCam;
        if (_cancel == null)
        {
            _cancel  = new Cancel();
            _decoder = Barcode.GetDecoder(Options);
            _decoder.Options.TryHarder = true;

#if NETFX_CORE
            IAsyncAction asyncAction = ThreadPool.RunAsync(workItem =>
            {
                DecodingWorker(_cancel);
            });
#else
            ThreadPool.QueueUserWorkItem(DecodingWorker, _cancel);
#endif
        }

        while (!_webCam.isPlaying)
        {
            yield return(null);
        }
    }
 public ScannerService(IBarcodeDecoder decoder)
 {
     this.decoder = decoder;
 }