SBSDKDocumentScannerViewControllerDelegate
@protocol SBSDKDocumentScannerViewControllerDelegate <NSObject>
The delegate protocol of ‘SBSDKDocumentScannerViewController’.
-
Informs the delegate that the document scanner detected and captured a document and provides the original image, the cropped document image and the result of the detection.
Declaration
Objective-C
- (void)documentScannerViewController: (nonnull SBSDKDocumentScannerViewController *)controller didSnapDocumentImage:(nonnull UIImage *)documentImage onImage:(nonnull UIImage *)originalImage withResult: (nonnull SBSDKDocumentDetectorResult *)result autoSnapped:(BOOL)autoSnapped;
Swift
func documentScannerViewController(_ controller: SBSDKDocumentScannerViewController, didSnapDocumentImage documentImage: UIImage, on originalImage: UIImage, with result: SBSDKDocumentDetectorResult, autoSnapped: Bool)
Parameters
controller
The document scanner controller that called this function.
documentImage
The image of the document: cropped, filtered and perspective corrected.
originalImage
The original image the document was detected on.
result
The result of the document detection.
autoSnapped
YES, if the result was automatically snapped, NO otherwise.
-
Optional. Asks the delegate whether it should run the document detection on the next video frame. Implement only if you need a very specific interruption of the detection. You do not need to implement this function if you want to interrupt the detection when the scanner view controller is invisible or covered by a presented view controller.
Declaration
Objective-C
- (BOOL)documentScannerViewControllerShouldDetectDocument: (nonnull SBSDKDocumentScannerViewController *)controller;
Swift
optional func documentScannerViewControllerShouldDetectDocument(_ controller: SBSDKDocumentScannerViewController) -> Bool
Parameters
controller
The document scanner controller that called this function.
Return Value
YES, if you want to run the document detection on the next video frame, NO otherwise.
-
Optional. Informs the delegate that the document scanner has processed a video frame. Called on main thread.
Declaration
Objective-C
- (void)documentScannerController: (nonnull SBSDKDocumentScannerViewController *)controller didSampleVideoFrame:(nonnull UIImage *)videoFrameImage detectionResult:(nonnull SBSDKDocumentDetectorResult *)result;
Swift
optional func documentScannerController(_ controller: SBSDKDocumentScannerViewController, didSampleVideoFrame videoFrameImage: UIImage, detectionResult result: SBSDKDocumentDetectorResult)
Parameters
controller
The document scanner controller that called this function.
videoFrameImage
An UIImage with the contents of the video frame.
result
The result of the document detection done on this video frame.
-
Optional. Informs the delegate that the document scanner controller is going to capture an image.
Declaration
Objective-C
- (void)documentScannerViewControllerWillSnapImage: (nonnull SBSDKDocumentScannerViewController *)controller;
Swift
optional func documentScannerViewControllerWillSnapImage(_ controller: SBSDKDocumentScannerViewController)
Parameters
controller
The document scanner controller that called this function.
-
Optional. Informs the delegate that snapping an image failed.
Declaration
Objective-C
- (void)documentScannerViewControllerDidFailSnappingImage: (nonnull SBSDKDocumentScannerViewController *)controller withError: (nullable NSError *)error;
Swift
optional func documentScannerViewControllerDidFailSnappingImage(_ controller: SBSDKDocumentScannerViewController, withError error: Error?)
Parameters
controller
The document scanner controller that called this function.
error
The error describing why the snapping failed.
-
Optional. Asks the delegate whether it should automatically snap an image when a document was detected on the video frame. Is not called if autoSnappingMode is set to SBSDKAutosnappingModeDisabled or SBSDKAutosnappingModeDisabledWithGuidance.
Declaration
Objective-C
- (BOOL)documentScannerViewController: (nonnull SBSDKDocumentScannerViewController *)controller shouldAutoSnapImageWithForDetectionResult: (nonnull SBSDKDocumentDetectorResult *)result;
Swift
optional func documentScannerViewController(_ controller: SBSDKDocumentScannerViewController, shouldAutoSnapImageWithForDetectionResult result: SBSDKDocumentDetectorResult) -> Bool
Parameters
controller
The document scanner controller that called this function.
result
The result of the document detection on the previous video frame.
Return Value
YES, if you want to schedule automatic snapping, NO otherwise.
-
Optional. Asks the delegate for the line color of the polygon that surrounds the detected polygon on the screen, depending on the document detection status.
Declaration
Objective-C
- (nonnull UIColor *) documentScannerViewController: (nonnull SBSDKDocumentScannerViewController *)controller polygonLineColorForStatus:(SBSDKDocumentDetectionStatus)status;
Swift
optional func documentScannerViewController(_ controller: SBSDKDocumentScannerViewController, polygonLineColorFor status: SBSDKDocumentDetectionStatus) -> UIColor
Parameters
controller
The document scanner controller that called this function.
status
The status of the current document detection.
Return Value
The line color for the displayed polygon.
-
Optional. Asks the delegate for the fill color of the polygon that surrounds the detected polygon on the screen, depending on the document detection status.
Declaration
Objective-C
- (nonnull UIColor *) documentScannerViewController: (nonnull SBSDKDocumentScannerViewController *)controller polygonFillColorForStatus:(SBSDKDocumentDetectionStatus)status;
Swift
optional func documentScannerViewController(_ controller: SBSDKDocumentScannerViewController, polygonFillColorFor status: SBSDKDocumentDetectionStatus) -> UIColor
Parameters
controller
The document scanner controller that called this function.
status
The status of the current document detection.
Return Value
The fill color for the displayed polygon.
-
Optional. Lets you configure the document detections status label, depending on the document detection status. You can change the visibility, colors, font and the text of the label here.
Declaration
Objective-C
- (void)documentScannerViewController: (nonnull SBSDKDocumentScannerViewController *)controller configureStatusDetectionLabel:(nonnull SBSDKDetectionStatusLabel *)label forDetectionResult: (nonnull SBSDKDocumentDetectorResult *)result;
Swift
optional func documentScannerViewController(_ controller: SBSDKDocumentScannerViewController, configureStatusDetectionLabel label: SBSDKDetectionStatusLabel, forDetectionResult result: SBSDKDocumentDetectorResult)
Parameters
controller
The document scanner controller that called this function.
label
The label to be configured.
result
The result of the current document detection.