private void Update() { var barcodeBitmap = webcam.GetPixels32(); var result = qr_decoder.Decode(barcodeBitmap, webcam.width, webcam.height); if (result.Success) { if ((result.BarcodeType == BarcodeType.QrCode) && !menu.GetComponent <Canvas>().enabled) { id = result.Text; } menu.GetComponent <Canvas>().enabled = true; } }
private IList <BarcodeSegment> Decode(string text) { if (decoder == null) { BarcodeSegment segment = new BarcodeSegment(); segment.Text = text; IList <BarcodeSegment> segments = new List <BarcodeSegment>(); segments.Add(segment); return(segments); } else { return(decoder.Decode(text)); } }
async Task Scan() { while (IsScanning) { Color32Result image = await UpdateCamera(); if (image != null) { string result = null; try { result = await m_BarcodeDecoder.Decode(image); } catch (Exception e) { Debug.LogError($"Error in Decoder {e}"); } if (result == null) { continue; } // Trigger attached actions try { m_Lock = true; m_Results.Add(result); m_Lock = null; } catch (Exception e) { Debug.LogError(e); } } else { Debug.LogError("Update Camera Failed!"); } await Task.Delay(100); } }