public override void LayoutSubviews() { base.LayoutSubviews(); nfloat largePadding = 20; nfloat x = largePadding; nfloat y = largePadding; nfloat w = Frame.Width - 2 * x; nfloat h = Frame.Width / 6; if (SBSDK.IsLicenseValid()) { h = 0; } LicenseIndicator.Frame = new CGRect(x, y, w, h); x = 0; y += h + largePadding; w = Frame.Width; h = DocumentScanner.Height; DocumentScanner.Frame = new CGRect(x, y, w, h); y += h + largePadding; h = DataDetectors.Height; DataDetectors.Frame = new CGRect(x, y, w, h); ContentSize = new CGSize(Frame.Width, DataDetectors.Frame.Bottom); }
void CropAndSaveImage() { processImageProgressBar.Visibility = ViewStates.Visible; cancelBtn.Visibility = ViewStates.Gone; doneBtn.Visibility = ViewStates.Gone; rotateCWButton.Visibility = ViewStates.Gone; Task.Run(() => { try { var detector = SDK.ContourDetector(); var documentImage = SDK.ImageProcessor().ProcessBitmap(originalBitmap, new CropOperation(editPolygonImageView.Polygon), false); documentImage = SBSDK.RotateImage(documentImage, -rotationDegrees); var documentImgUri = MainApplication.TempImageStorage.AddImage(documentImage); RunOnUiThread(() => { var extras = new Bundle(); extras.PutString(EXTRAS_ARG_IMAGE_FILE_URI, documentImgUri.ToString()); var intent = new Intent(); intent.PutExtras(extras); SetResult(Result.Ok, intent); Finish(); }); } catch (Exception e) { ErrorLog("Could not apply image changes", e); } }); }
private async void TakePhoto_Click(object sender, EventArgs e) { try { _camera.StopPreview(); var imageBitmap = _textureView.Bitmap; analyseButton.Visibility = ViewStates.Visible; retakeButton.Visibility = ViewStates.Visible; takePhoto.Visibility = ViewStates.Invisible; using (var imageStream = new MemoryStream()) { var preparedBitmap = ImagePreparer.PrepareForRecognition(imageBitmap); preparedBitmap = SBSDK.ApplyImageFilter(preparedBitmap, ScanbotSDK.Xamarin.ImageFilter.Binarized); await preparedBitmap.CompressAsync(Bitmap.CompressFormat.Jpeg, 100, imageStream); img = preparedBitmap.Copy(preparedBitmap.GetConfig(), true); imageBitmap.Recycle(); //resizedBitmap.Recycle(); preparedBitmap.Recycle(); }; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("*************************\n" + ex.Message); } }
void RunDocumentDetection(NSUrl imgurl) { DebugLog("Performing document detection on image " + imgurl); Task.Run(() => { // The SDK call is sync! var detectionResult = SBSDK.DetectDocument(imgurl); if (detectionResult.Status.IsOk()) { var imageResult = detectionResult.Image as UIImage; DebugLog("Detection result image: " + imageResult); documentImageUrl = AppDelegate.TempImageStorage.AddImage(imageResult); ShowImageView(imageResult); DebugLog("Detection result polygon: "); string resultString = ""; foreach (var p in detectionResult.Polygon) { resultString += p + "\n"; } DebugLog(resultString); } else { DebugLog("No Document detected! DetectionStatus = " + detectionResult.Status); ShowErrorMessage("No Document detected! DetectionStatus = " + detectionResult.Status); } }); }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); if (!SBSDK.IsLicenseValid()) { ContentView.LayoutSubviews(); } foreach (ScannerButton button in ContentView.DocumentScanner.Buttons) { button.Click += OnScannerButtonClick; } foreach (ScannerButton button in ContentView.BarcodeDetectors.Buttons) { button.Click += OnBarcodeButtonClick; } foreach (ScannerButton button in ContentView.DataDetectors.Buttons) { button.Click += OnDataButtonClick; } CameraCallback.Selected += OnScanComplete; }
void SaveDocument(SaveType type) { if (!SBSDK.IsLicenseValid()) { Alert.ShowLicenseDialog(this); return; } Task.Run(delegate { var input = adapter.GetDocumentUris().ToArray(); var output = GetOutputUri(".pdf"); if (type == SaveType.TIFF) { output = GetOutputUri(".tiff"); // Please note that some compression types are only compatible for 1-bit encoded images (binarized black & white images)! var options = new TiffOptions { OneBitEncoded = true, Compression = TiffCompressionOptions.CompressionCcittfax4, Dpi = 250 }; bool success = SBSDK.WriteTiff(input, output, options); } else if (type == SaveType.OCR) { var languages = SBSDK.GetOcrConfigs().InstalledLanguages.ToArray(); if (languages.Length == 0) { RunOnUiThread(delegate { Alert.Toast(this, "OCR languages blobs are not available"); }); return; } SBSDK.PerformOCR(input, languages, output); } else { SBSDK.CreatePDF(input, output, ScanbotSDK.Xamarin.PDFPageSize.FixedA4); } Java.IO.File file = Copier.Copy(this, output); var intent = new Intent(Intent.ActionView, output); var authority = ApplicationContext.PackageName + ".provider"; var uri = FileProvider.GetUriForFile(this, authority, file); intent.SetDataAndType(uri, MimeUtils.GetMimeByName(file.Name)); intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask); intent.AddFlags(ActivityFlags.GrantReadUriPermission | ActivityFlags.GrantWriteUriPermission); RunOnUiThread(delegate { StartActivity(Intent.CreateChooser(intent, output.LastPathSegment)); Alert.Toast(this, "File saved to: " + output.Path); }); }); }
bool CheckScanbotSDKLicense() { if (SBSDK.IsLicenseValid()) { // Trial period, valid trial license or valid production license. return(true); } Toast.MakeText(this, "Scanbot SDK (trial) license has expired!", ToastLength.Long).Show(); return(false); }
protected override void OnResume() { base.OnResume(); if (!SBSDK.IsLicenseValid()) { Alert.ShowLicenseDialog(this); } UpdateVisibility(); }
protected void ApplyFilterOnDocumentImage(ImageFilter filter) { DebugLog("Applying image filter on " + documentImageUrl); Task.Run(() => { // The SDK call is sync! var resultImage = SBSDK.ApplyImageFilter(documentImageUrl, filter); DebugLog("Image filter result: " + resultImage); ShowImageView(resultImage); }); }
bool CheckScanbotSDKLicense() { if (SBSDK.IsLicenseValid()) { // Trial period, valid trial license or valid production license. return(true); } ShowErrorMessage("Scanbot SDK (trial) license has expired!"); return(false); }
public override void OnCreate() { base.OnCreate(); Log.Debug(LOG_TAG, "Initializing Scanbot SDK..."); SBSDK.Initialize(this, LICENSE_KEY, new SBSDKConfiguration { EnableLogging = true }); // In this example we always cleanup the demo temp storage directory on app start. TempImageStorage.CleanUp(); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { Console.WriteLine("Scanbot SDK Example: Initializing Scanbot SDK..."); SBSDK.Initialize(application, LICENSE_KEY, new SBSDKConfiguration { EnableLogging = true }); // In this example we always cleanup the demo temp storage directory on app start. TempImageStorage.CleanUp(); return(true); }
public override void OnCreate() { base.OnCreate(); Log.Debug(LOG_TAG, "Initializing Scanbot SDK..."); // Initialization with a custom, public(!) "StorageBaseDirectory" for demo purposes - see comments below! SBSDK.Initialize(this, LICENSE_KEY, new SBSDKConfiguration { EnableLogging = true, StorageBaseDirectory = GetDemoStorageBaseDirectory() }); // Alternative initialization with the default "StorageBaseDirectory" which will be internal and secure (recommended). //SBSDK.Initialize(this, LICENSE_KEY, new SBSDKConfiguration { EnableLogging = true }); }
bool CheckLicense() { if (SBSDK.IsLicenseValid()) { LicenseIndicator.Visibility = ViewStates.Gone; } else { LicenseIndicator.Visibility = ViewStates.Visible; Alert.Toast(this, "Invalid or missing license"); } return(SBSDK.IsLicenseValid()); }
void AssignOcrButtonsHandler() { performOcrButton = FindViewById <Button>(Resource.Id.performOcrButton); performOcrButton.Click += delegate { if (!CheckScanbotSDKLicense()) { return; } if (!CheckDocumentImage()) { return; } performOcrButton.Post(() => { performOcrButton.Text = "Running OCR ... Please wait ..."; performOcrButton.Enabled = false; }); Task.Run(() => { try { var pdfOutputUri = GenerateRandomFileUrlInDemoTempStorage(".pdf"); var images = new AndroidNetUri[] { documentImageUri }; // add more images for OCR here // The SDK call is sync! var result = SBSDK.PerformOCR(images, new [] { "en", "de" }, pdfOutputUri); DebugLog("Recognized OCR text: " + result.RecognizedText); DebugLog("Sandwiched PDF file created: " + pdfOutputUri); ShowAlertDialog(result.RecognizedText, "OCR Result", () => { OpenSharingDialog(pdfOutputUri, "application/pdf"); }); } catch (Exception e) { ErrorLog("Error performing OCR", e); } finally { performOcrButton.Post(() => { performOcrButton.Text = "Perform OCR"; performOcrButton.Enabled = true; }); } }); }; }
void ApplyImageFilter(ImageFilter filter) { DebugLog("Applying image filter " + filter + " on image: " + documentImageUri); try { Task.Run(() => { // The SDK call is sync! var resultImage = SBSDK.ApplyImageFilter(documentImageUri, filter); documentImageUri = MainApplication.TempImageStorage.AddImage(resultImage); ShowImageView(resultImage); }); } catch (Exception e) { ErrorLog("Error applying image filter", e); } }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { Console.WriteLine("Scanbot SDK Example: Initializing Scanbot SDK..."); // Initialization with a custom, public(!) "StorageBaseDirectory" for demo purposes - see comments below! var configuration = new SBSDKConfiguration { EnableLogging = true, StorageBaseDirectory = GetDemoStorageBaseDirectory() }; SBSDK.Initialize(application, LICENSE_KEY, configuration); // Alternative initialization with the default "StorageBaseDirectory" which will be internal and secure (recommended). //SBSDK.Initialize(application, LICENSE_KEY, new SBSDKConfiguration { EnableLogging = true }); UIViewController initial = new MainViewController(); Controller = new UINavigationController(initial); // Navigation bar background color Controller.NavigationBar.BarTintColor = Colors.ScanbotRed; // Back button color Controller.NavigationBar.TintColor = UIColor.White; Controller.NavigationBar.Translucent = false; // Title color Controller.NavigationBar.TitleTextAttributes = new UIStringAttributes { ForegroundColor = UIColor.White, Font = UIFont.FromName("HelveticaNeue", 16) }; Window = new UIWindow(UIScreen.MainScreen.Bounds); Window.RootViewController = Controller; TopInset = Controller.NavigationBar.Frame.Height + UIApplication.SharedApplication.StatusBarFrame.Height; Window.MakeKeyAndVisible(); return(true); }
partial void PerformOCRUpInside(UIButton sender) { if (!CheckScanbotSDKLicense()) { return; } if (!CheckDocumentImageUrl()) { return; } Task.Run(() => { DebugLog("Performing OCR ..."); var images = new NSUrl[] { documentImageUrl }; var result = SBSDK.PerformOCR(images, new[] { "en", "de" }); DebugLog("OCR result: " + result.RecognizedText); ShowMessage("OCR Text", result.RecognizedText); }); }
partial void CreatePdfTouchUpInside(UIButton sender) { if (!CheckScanbotSDKLicense()) { return; } if (!CheckDocumentImageUrl()) { return; } Task.Run(() => { DebugLog("Creating PDF file ..."); var images = new NSUrl[] { documentImageUrl }; // add more images for multipage PDF var pdfOutputFileUrl = GenerateRandomFileUrlInDemoTempStorage(".pdf"); SBSDK.CreatePDF(images, pdfOutputFileUrl, PDFPageSize.FixedA4); DebugLog("PDF file created: " + pdfOutputFileUrl); ShowMessage("PDF file created", "" + pdfOutputFileUrl); }); }
void AssignCreateTiffButtonHandler() { var createTiffButton = FindViewById <Button>(Resource.Id.createTiffButton); createTiffButton.Click += delegate { if (!CheckScanbotSDKLicense()) { return; } if (!CheckDocumentImage()) { return; } DebugLog("Starting TIFF creation..."); Task.Run(() => { try { var tiffOutputUri = GenerateRandomFileUrlInDemoTempStorage(".tiff"); var images = new AndroidNetUri[] { documentImageUri }; // add more images for PDF pages here // The SDK call is sync! SBSDK.WriteTiff(images, tiffOutputUri, new TiffOptions { OneBitEncoded = true }); DebugLog("TIFF file created: " + tiffOutputUri); ShowAlertDialog("TIFF file created: " + tiffOutputUri, onDismiss: () => { OpenSharingDialog(tiffOutputUri, "image/tiff"); }); } catch (Exception e) { ErrorLog("Error creating TIFF", e); } }); }; }
private void DetectDocument(Bitmap bitmap) { if (!CheckScanbotSDKLicense()) { return; } //store original image as file var originalImgUri = MainApplication.TempImageStorage.AddImage(bitmap); var detectionResult = SBSDK.DetectDocument(bitmap); DebugLog("Document detection result: " + detectionResult.Status); if (detectionResult.Status.IsOk()) { var documentImage = detectionResult.Image as Bitmap; imageView1.SetImageBitmap(documentImage); //Store data as docu file documentImageUri = MainApplication.TempImageStorage.AddImage(documentImage); DebugLog("Detected polygon: "); foreach (var p in detectionResult.Polygon) { DebugLog(p.ToString()); } } else { //No docu! documentImageUri = originalImgUri; DebugLog("No document detected!"); } if (documentImageUri != null) { RecognizeText(); } }
void AssignCreatePdfButtonHandler() { var createPdfButton = FindViewById <Button>(Resource.Id.createPdfButton); createPdfButton.Click += delegate { if (!CheckScanbotSDKLicense()) { return; } if (!CheckDocumentImage()) { return; } DebugLog("Starting PDF creation..."); Task.Run(() => { try { var pdfOutputUri = GenerateRandomFileUrlInDemoTempStorage(".pdf"); var images = new AndroidNetUri[] { documentImageUri }; // add more images for PDF pages here // The SDK call is sync! SBSDK.CreatePDF(images, pdfOutputUri, PDFPageSize.FixedA4); DebugLog("PDF file created: " + pdfOutputUri); ShowAlertDialog("PDF file created: " + pdfOutputUri, onDismiss: () => { OpenSharingDialog(pdfOutputUri, "application/pdf"); }); } catch (Exception e) { ErrorLog("Error creating PDF", e); } }); }; }
void RunDocumentDetection(AndroidNetUri imageUri) { DebugLog("Running document detection on image: " + imageUri); Task.Run(() => { try { // The SDK call is sync! var detectionResult = SBSDK.DetectDocument(imageUri, this); DebugLog("Document detection result: " + detectionResult.Status); if (detectionResult.Status.IsOk()) { var documentImage = detectionResult.Image as Bitmap; documentImageUri = MainApplication.TempImageStorage.AddImage(documentImage); ShowImageView(documentImage); DebugLog("Detected polygon: "); foreach (var p in detectionResult.Polygon) { DebugLog(p.ToString()); } } else { DebugLog("No document detected!"); RunOnUiThread(() => { Toast.MakeText(this, "No document detected! (Detection result: " + detectionResult.Status + ")", ToastLength.Long).Show(); }); } } catch (Exception e) { ErrorLog("Error while document detection", e); } }); }
partial void CreateTiffFileTouchUpInside(UIButton sender) { if (!CheckScanbotSDKLicense()) { return; } if (!CheckDocumentImageUrl()) { return; } Task.Run(() => { DebugLog("Creating TIFF file ..."); var images = new NSUrl[] { documentImageUrl }; // add more images for multipage TIFF var tiffOutputFileUrl = GenerateRandomFileUrlInDemoTempStorage(".tiff"); SBSDK.WriteTiff(images, tiffOutputFileUrl, new TiffOptions { OneBitEncoded = true }); DebugLog("TIFF file created: " + tiffOutputFileUrl); ShowMessage("TIFF file created", "" + tiffOutputFileUrl); }); }
public App() { InitializeComponent(); var content = new MainPage(); MainPage = new NavigationPage(content) { BarBackgroundColor = Color.FromRgb(200, 25, 60), BarTextColor = Color.White }; SBSDK.Initialize(new ScanbotBarcodeSDK.Forms.InitializationOptions { LicenseKey = Key, LoggingEnabled = true, ErrorHandler = (status, feature) => { var message = $"Error! Status: {status}; Your license is missing the feature: {feature}"; Console.WriteLine(message); } }); }
public void OnPictureTaken(byte[] image, int imageOrientation) { // Here we get the full image from the camera. Bitmap processedImage = BitmapFactory.DecodeByteArray(image, 0, image.Length, new BitmapFactory.Options()); // Run document detection on image: var detectionResult = SBSDK.DocumentDetection(processedImage); if (detectionResult.Status.IsOk()) { processedImage = detectionResult.Image as Bitmap; } processedImage = ImagePreparer.PrepareForRecognition(processedImage); Image = processedImage; Intent itemView = new Intent(this, typeof(ItemDisplayer)); StartActivity(itemView); }
private void OnScannerButtonClick(object sender, EventArgs e) { if (!SBSDK.IsLicenseValid()) { ContentView.LayoutSubviews(); return; } var button = (ScannerButton)sender; if (button.Data.Code == ListItemCode.ScanDocument) { var config = SBSDKUIDocumentScannerConfiguration.DefaultConfiguration; config.BehaviorConfiguration.MultiPageEnabled = true; config.BehaviorConfiguration.IgnoreBadAspectRatio = true; config.TextConfiguration.PageCounterButtonTitle = "%d Page(s)"; config.TextConfiguration.TextHintOK = "Don't move.\nCapturing document..."; config.UiConfiguration.BottomBarBackgroundColor = UIColor.Blue; config.UiConfiguration.BottomBarButtonsColor = UIColor.White; // see further customization configs... var controller = SBSDKUIDocumentScannerViewController .CreateNewWithConfiguration(config, CameraCallback); controller.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; PresentViewController(controller, false, null); } else if (button.Data.Code == ListItemCode.ImportImage) { ImagePicker.Instance.Present(this); ImagePicker.Instance.Controller.FinishedPickingMedia += ImageImported; } else if (button.Data.Code == ListItemCode.ViewImages) { OpenImageListController(); } }
private void RecognizeText() { String status = "reading the recognized text"; SpeakStatus(status); Task.Run(() => { try { if (!CheckScanbotSDKLicense()) { return; } var images = new AndroidNetUri[] { documentImageUri }; // SDK call is sync var result = SBSDK.PerformOCR(images, new[] { "en", "de" }); DebugLog("Recognized OCR text: " + result.RecognizedText); //switch to readbraille layout Intent nextActivity = new Intent(this, typeof(ReadBraille)); nextActivity.PutExtra("text", result.RecognizedText); if (nextActivity == null) { return; } StartActivity(nextActivity); } catch (Exception e) { ErrorLog("Error performing OCR", e); } }); }
private void OnDataButtonClick(object sender, EventArgs e) { if (!SBSDK.IsLicenseValid()) { ContentView.LayoutSubviews(); return; } var button = (ScannerButton)sender; if (button.Data.Code == ListItemCode.ScannerMRZ) { var config = SBSDKUIMachineCodeScannerConfiguration.DefaultConfiguration; config.TextConfiguration.CancelButtonTitle = "Done"; //config.TextConfiguration.FinderTextHint = "Custom finder text ..." // see further customization configs var viewSize = View.Frame.Size; var targetWidth = viewSize.Width - ((viewSize.Width * 0.058) * 2); var aspect = new SBSDKAspectRatio(targetWidth, targetWidth * 0.3); config.UiConfiguration.FinderAspectRatio = aspect; var controller = SBSDKUIMRZScannerViewController .CreateNewWithConfiguration(config, Delegates.MRZ); PresentViewController(controller, true, null); } else if (button.Data.Code == ListItemCode.WorkflowDC) { var ratios = new SBSDKAspectRatio[] { // DC form A5 portrait (e.g. white sheet, AUB Muster 1b/E (1/2018)) new SBSDKAspectRatio(148.0, 210.0), // DC form A6 landscape (e.g. yellow sheet, AUB Muster 1b (1.2018)) new SBSDKAspectRatio(148.0, 105.0) }; var title = "Please align the DC form in the frame."; var name = "DisabilityCertificateFlow"; var steps = new SBSDKUIWorkflowStep[] { new SBSDKUIScanDisabilityCertificateWorkflowStep( title, "", ratios, true, WorkflowStepValidator.OnDCFormStep ) }; PresentController(name, steps); } else if (button.Data.Code == ListItemCode.WorkflowMRZImage) { var title = "Please align the Machine readable card with the form in the frame"; var name = "MRZScanFlow"; var steps = new SBSDKUIWorkflowStep[] { new SBSDKUIScanMachineReadableZoneWorkflowStep( title, "", MRZRatios, true, WorkflowStepValidator.OnIDCardBackStep ) }; PresentController(name, steps); } else if (button.Data.Code == ListItemCode.WorkflowMRZFrontBack) { var name = "MRZBackFrontScanFlow"; var steps = new SBSDKUIWorkflowStep[] { new SBSDKUIWorkflowStep( "Step 1/2", "Please scan the front side of your ID card", MRZRatios, true, false, null, WorkflowStepValidator.OnIDCardFrontStep ), new SBSDKUIScanMachineReadableZoneWorkflowStep( "Step 2/2", "Please scan the back side of your ID card", MRZRatios, true, WorkflowStepValidator.OnIDCardBackStep ) }; PresentController(name, steps); } else if (button.Data.Code == ListItemCode.WorkflowSEPA) { var name = "SEPAScanFlow"; var steps = new SBSDKUIWorkflowStep[] { new SBSDKUIScanPayFormWorkflowStep( "Please scan a SEPA PayForm", "", false, WorkflowStepValidator.OnPayFormStep ) }; PresentController(name, steps); } else if (button.Data.Code == ListItemCode.WorkflowQR) { var name = "QRCodeScanFlow"; var types = SBSDKUIMachineCodesCollection.TwoDimensionalBarcodes; var steps = new SBSDKUIWorkflowStep[] { new SBSDKUIScanBarCodeWorkflowStep("Scan your QR code", "", types, new SBSDKAspectRatio(1, 1), WorkflowStepValidator.OnBarCodeStep) }; PresentController(name, steps); } else if (button.Data.Code == ListItemCode.ScannerEHIC) { var configuration = SBSDKUIHealthInsuranceCardScannerConfiguration.DefaultConfiguration; var controller = SBSDKUIHealthInsuranceCardScannerViewController .CreateNewWithConfiguration(configuration, Delegates.EHIC); controller.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; PresentViewController(controller, false, null); } else if (button.Data.Code == ListItemCode.ScannerBarcode) { var configuration = SBSDKUIMachineCodeScannerConfiguration.DefaultConfiguration; var controller = SBSDKUIBarcodeScannerViewController .CreateNewWithAcceptedMachineCodeTypes( SBSDKBarcodeType.AllTypes, configuration, Delegates.Barcode); controller.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; PresentViewController(controller, false, null); } }
public void OnPictureTaken(byte[] image, int imageOrientation) { // Here we get the full image from the camera and apply document detection on it. // Implement a suitable async(!) detection and image handling here. // This is just a demo showing detected image as downscaled preview image. Log.Debug(LOG_TAG, "OnPictureTaken: imageOrientation = " + imageOrientation); // Show progress spinner: RunOnUiThread(() => { imageProcessingProgress.Visibility = ViewStates.Visible; userGuidanceTextView.Visibility = ViewStates.Gone; }); // decode bytes as Bitmap BitmapFactory.Options options = new BitmapFactory.Options(); options.InSampleSize = 1; var originalBitmap = BitmapFactory.DecodeByteArray(image, 0, image.Length, options); // rotate original image if required: if (imageOrientation > 0) { Matrix matrix = new Matrix(); matrix.SetRotate(imageOrientation, originalBitmap.Width / 2f, originalBitmap.Height / 2f); originalBitmap = Bitmap.CreateBitmap(originalBitmap, 0, 0, originalBitmap.Width, originalBitmap.Height, matrix, false); } // Store the original image as file: var originalImgUri = MainApplication.TempImageStorage.AddImage(originalBitmap); Android.Net.Uri documentImgUri = null; // Run document detection on original image: var detectionResult = SBSDK.DetectDocument(originalBitmap); if (detectionResult.Status.IsOk()) { var documentImage = detectionResult.Image as Bitmap; // Store the document image as file: documentImgUri = MainApplication.TempImageStorage.AddImage(documentImage); } else { // No document detected! Use original image as document image, so user can try to apply manual cropping. documentImgUri = originalImgUri; } //this.detectedPolygon = detectionResult.Polygon; Bundle extras = new Bundle(); extras.PutString(EXTRAS_ARG_DOC_IMAGE_FILE_URI, documentImgUri.ToString()); extras.PutString(EXTRAS_ARG_ORIGINAL_IMAGE_FILE_URI, originalImgUri.ToString()); Intent intent = new Intent(); intent.PutExtras(extras); SetResult(Result.Ok, intent); Finish(); return; /* If you want to continue scanning: * RunOnUiThread(() => { * // continue camera preview * cameraView.StartPreview(); * cameraView.ContinuousFocus(); * }); */ }