Beispiel #1
0
        private async Task Scan()
        {
            var status = await Permissions.CheckStatusAsync <Permissions.Camera>();

            if (status != PermissionStatus.Granted)
            {
                status = await Permissions.RequestAsync <Permissions.Camera>();
            }

            if (status != PermissionStatus.Granted)
            {
                return;
            }

            try
            {
                var photo = await MediaPicker.CapturePhotoAsync();

                using (var stream = await photo.OpenReadAsync())
                {
                    var scanResults = await _ocrService.ProcessImage(stream);

                    _currentImageService.ScanResult = scanResults;
                    await _navigationService.NavigateAsync(nameof(ScanPreviewPage));
                }

                //await LoadPhotoAsync(photo);
                //Console.WriteLine($"CapturePhotoAsync COMPLETED: {PhotoPath}");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"CapturePhotoAsync THREW: {ex.Message}");
            }
        }
Beispiel #2
0
        private string ScrapeImage(Bitmap image)
        {
            using (MemoryStream memoryStream = new MemoryStream())
            {
                image.Save(memoryStream, ImageFormat.Tiff);

                return(_ocrService.ProcessImage(memoryStream));
            }
        }