// Update is called once per frame public void Update() { //Wait for camera to get ready if (!Camera.IsReady()) { Debug.Log("Camera is not ready yet."); if (status != DeviceCamera.ReadStatus.İnitialize) { status = DeviceCamera.ReadStatus.İnitialize; } return; } if (Status == DeviceCamera.ReadStatus.İnitialize) { if (WebcamInitialized()) { Debug.Log("Camera is READY!"); Status = DeviceCamera.ReadStatus.Paused; if (OnReady != null) { OnReady.Invoke(this, EventArgs.Empty); } } } if (Status == DeviceCamera.ReadStatus.Running) { if (qrResult != null) { Debug.Log(qrResult); Callback(qrResult.Type, qrResult.Value); //Empty qrResult = null; parserPixelAvailable = false; return; } pixels = Camera.GetPixels(pixels); parserPixelAvailable = true; // If background thread OFF, do the decode main thread with 500ms of pause for UI if (!deviceCamOptions.ScannerBackgroundThread && mainThreadLastDecode < Time.realtimeSinceStartup - deviceCamOptions.ScannerDecodeInterval) { DecodeQR(); mainThreadLastDecode = Time.realtimeSinceStartup; } } }
public QRCodeReader(DeviceCameraOptions settings, IResult result, IDeviceCam webcam) { if (Application.HasUserAuthorization(UserAuthorization.WebCam)) { Application.RequestUserAuthorization(UserAuthorization.WebCam); //throw new Exception("You need to have permission to use Webcam!"); } status = DeviceCamera.ReadStatus.İnitialize; // Default Properties deviceCamOptions = (deviceCamOptions == null) ? new DeviceCameraOptions(512, 512, FilterMode.Trilinear) : deviceCamOptions; Result = (result == null) ? new ZXingParser(deviceCamOptions) : result; Camera = (webcam == null) ? new DeviceCamera(deviceCamOptions) : webcam; }