public void OnPreviewFrame(byte[] data, Camera camera) { var pars = camera.GetParameters(); var imageformat = pars.PreviewFormat; if (imageformat == ImageFormatType.Nv21) { byte[] jpegData = ConvertYuvToJpeg(data, camera); Frame frame = new Frame.Builder().SetBitmap(bytesToBitmap(jpegData)).Build(); //SparseArray barcodes = barcodeDetector.Detect(frame); barcodeDetector.ReceiveFrame(frame); } }
public Task <ScanResult> ProcessImage(Stream bitmapStream) { if (!_recognizer.IsOperational) { throw new Exception("Recognizer not operational."); } using var bitmap = BitmapFactory.DecodeStream(bitmapStream); using var frame = new Frame.Builder().SetBitmap(bitmap).Build(); using var results = _recognizer.Detect(frame); var result = new ScanResult(); for (var i = 0; i < results.Size(); i++) { var androidBlock = (TextBlock)results.ValueAt(i); if (androidBlock != null) { result.Add(GetBlock(androidBlock)); } } return(Task.FromResult(result)); }