SBSDKScannerViewController

@interface SBSDKScannerViewController : UIViewController

UIViewController subclass showing a camera screen and running a user guiding Document detector. Detection result is visualized using a polygonal bezier path. This class cannot be instanced from a storyboard. Instead it is installing itself as a child view controller onto a given parent view controller.

  • The delegate. See SBSDKScannerViewControllerDelegate protocol. Weak.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<SBSDKScannerViewControllerDelegate>
        delegate;

    Swift

    weak var delegate: SBSDKScannerViewControllerDelegate? { get set }
  • The controllers camera session.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nonnull)
        SBSDKCameraSession *cameraSession;

    Swift

    var cameraSession: SBSDKCameraSession { get }
  • YES, if energy saving is active. NO otherwise. Energy saving becomes active when shutter mode is SBSDKShutterModeSmart and, for a certain time no document has been detected and the device was not moved significantly.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL energySavingActive;

    Swift

    var energySavingActive: Bool { get }
  • The desired maximum detection rate of the receicer. The maximum number of video frames per second to

    • be analyzed. Defaults to 20.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSUInteger detectionRate;

    Swift

    var detectionRate: UInt { get set }
  • If set to YES (default), the camera session will be stopped entirely, when the receiver disappears and restarts when the receiver reappears. There is no CPU usage while the receiver is not on screen.

    NO will NOT stop the camera session, but pause the delivery of video frames and QR codes. There is some very low CPU activity while the receiver is not on screen, but there is also no lag when the receiver returns to the screen.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL stopsCameraSessionWhenDisappeared;

    Swift

    var stopsCameraSessionWhenDisappeared: Bool { get set }
  • The image storage. If not nil, cropped document images will be saved there, independently from what the delegate is doing. Weak.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<SBSDKImageStoring> imageStorage;

    Swift

    weak var imageStorage: SBSDKImageStoring? { get set }
  • Scaling factor being applied to captured still shots before processing. Must be in the range 0.0 < imageScale <= 1.0. Invalid values are threated as 1.0. Defaults to 0.8. Used to scale images before processing them. Lower numbers reduce memory pressure.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat imageScale;

    Swift

    var imageScale: CGFloat { get set }
  • Sensitivity factor for automatic capturing. Must be in the range [0.0…1.0]. Invalid values are threated as 1.0. Defaults to 0.66 (1 sec).s A value of 1.0 triggers automatic capturing immediately, a value of 0.0 delays the automatic by 3 seconds.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat autoCaptureSensitivity;

    Swift

    var autoCaptureSensitivity: CGFloat { get set }
  • The minimum size in percent (0 - 100) of the screen size to accept a detected document. It is sufficient that height or width match the score. Default is 80.0. Warning: Lower values result in low resolution document images.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) double acceptedSizeScore;

    Swift

    var acceptedSizeScore: Double { get set }
  • The minimum score in percent (0 - 100) of the perspective distortion to accept a detected document. Default is 75.0. Set lower values to accept more perspective distortion. Warning: Lower values result in more blurred document images.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) double acceptedAngleScore;

    Swift

    var acceptedAngleScore: Double { get set }
  • Preferred aspect ratios for detector.

    • If nil or empty, aspect ratio will not take part in defining best document polygon.
    • If set, polygons with set aspect ratio will be more preferrable.
    • Default is nil.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        NSArray<SBSDKPageAspectRatio *> *preferredAspectRatios;

    Swift

    var preferredAspectRatios: [SBSDKPageAspectRatio]? { get set }
  • Required aspect ratios for detector.

    • If not nil or empty, only polygons resulting in crops with one of the required aspect ratios will be detected.
    • Default is nil.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        NSArray<SBSDKPageAspectRatio *> *requiredAspectRatios;

    Swift

    var requiredAspectRatios: [SBSDKPageAspectRatio]? { get set }
  • The orientation captured images are locked onto. By default it is SBSDKOrientationLockNone. Setting this property to any other value will suppress the document detection status ‘SBSDKDocumentDetectionStatusOK_BadAspectRatio’. If the lock is enabled the detection status UI will be orientation-locked too.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        SBSDKOrientationLock imageOrientationLock;

    Swift

    var imageOrientationLock: SBSDKOrientationLock { get set }
  • Hides or unhides the shutter button.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL shutterButtonHidden;

    Swift

    var shutterButtonHidden: Bool { get set }
  • Hides or unhides the detection status label and polygon layer.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL detectionStatusHidden;

    Swift

    var detectionStatusHidden: Bool { get set }
  • The view finder mode of the receiver. Defaults to SBSDKFinderModeAspectRatioAutomatic.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) SBSDKFinderMode finderMode;

    Swift

    var finderMode: SBSDKFinderMode { get set }
  • If this property is set to YES, then SBSDKDocumentDetectionStatusOK_BadAspectRatio status will be suppressed and treated as SBSDKDocumentDetectionStatusOK. Default is NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL ignoreBadAspectRatio;

    Swift

    var ignoreBadAspectRatio: Bool { get set }
  • Machine code types (EAN, DataMatrix, Aztec, QR, etc) that can be returned in didDetectMachineReadableCodes delegate method. When nil - all codes can be returned. Default is nil.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        NSArray<AVMetadataObjectType> *acceptedMachineCodeTypes;

    Swift

    var acceptedMachineCodeTypes: [AVMetadataObject.ObjectType]? { get set }
  • The scanning state of the receiver. See SBSDKScannerStatus.

    Declaration

    Objective-C

    @property (readonly, nonatomic) int scannerStatus;

    Swift

    var scannerStatus: SBSDKScannerStatus { get }
  • The receivers shutter mode. See SBSDKShutterMode. Defaults to SBSDKShutterModeSmart.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) SBSDKShutterMode shutterMode;

    Swift

    var shutterMode: SBSDKShutterMode { get set }
  • Whether the receiver automatically releases the shutter or not. Powerful energy saver if combined with the delegate method (BOOL)scannerControllerShouldAnalyseVideoFrame:(SBSDKScannerViewController *)controller. If you return controller.autoShutterEnabled here the document detection is toggled off until you re-enable the auto shutter or significantly move your device.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL autoShutterEnabled;

    Swift

    var autoShutterEnabled: Bool { get }
  • The instance of the automatically created shutter button. If the receivers view is not loaded the property is nil. Setting a custom shutter button has no impact on the property.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) UIButton *defaultShutterButton;

    Swift

    var defaultShutterButton: UIButton? { get }
  • Specifies the format of the captured images handled via the delegate methods. Use SBSDKImageModeGrayscale if a grayscale image is sufficient and to avoid memory pressure. Defaults to SBSDKImageModeColor.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) int imageMode;

    Swift

    var imageMode: SBSDKImageMode { get set }
  • A transparent view that lies over the preview layer. You can add custom UI here. Read-only.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nonnull) UIView *HUDView;

    Swift

    var hudView: UIView { get }
  • Background color of detection status label. Default is red with alpha 0.5. Can be nil.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        UIColor *detectionStatusBackgroundColor;

    Swift

    var detectionStatusBackgroundColor: UIColor? { get set }
  • Text color of detection status label. Default is white. Can be nil.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        UIColor *detectionStatusTextColor;

    Swift

    var detectionStatusTextColor: UIColor? { get set }
  • Font of detection status label. Default is system font with size 17. Can be nil.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UIFont *detectionStatusFont;

    Swift

    var detectionStatusFont: UIFont? { get set }
  • Background color of camera preview. Default is black. Can be nil.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        UIColor *previewBackgroundColor;

    Swift

    var previewBackgroundColor: UIColor? { get set }
  • Background color of the view finder. Default is white with 0.66 alpha. Must not be nil.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nonnull)
        UIColor *viewFinderBackgroundColor;

    Swift

    var viewFinderBackgroundColor: UIColor { get set }
  • Not available.

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Not available.

    Declaration

    Objective-C

    + (nonnull instancetype)new;
  • Line color of the view finder. Default is nil, which draws no border line for the view finder.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) UIColor *viewFinderLineColor;

    Swift

    var viewFinderLineColor: UIColor? { get set }
  • The current rectangle of the view finder if displayed, CGRectZero otherwise.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGRect currentViewFinderRect;

    Swift

    var currentViewFinderRect: CGRect { get }
  • Defines the region of interest when scanning barcodes or other machine readable codes. Machine readable codes found outside this region of interest are discarded and ignored during detection. The property describes the aspect ratio (capturingFrameSize.width / capturingFrameSize.height) of the region of interest. This aspect ratio, in conjunction with the screen size, is used to create an absolute region of interest and render a view finder like rounded rectangle on screen. Setting this property to (0.0, 0.0) or CGSizeZero effectively disables the region of interest.

    Example: (1.0, 1.0) will create a quadratic region of interest, filling most of the screen area, a good match for scanning QR codes.

    Note: Only effective if finderMode equals SBSDKFinderModeCapturingFrame.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGSize capturingFrameSize;

    Swift

    var capturingFrameSize: CGSize { get set }
  • Desginated initializer. Installs the receiver as child view controller onto the parent view controllers view using its entire bounds area.

    Declaration

    Objective-C

    - (nonnull instancetype)
        initWithParentViewController:
            (nonnull UIViewController *)parentViewController
                        imageStorage:(nullable id<SBSDKImageStoring>)storage;

    Swift

    init(parentViewController: UIViewController, imageStorage storage: SBSDKImageStoring?)

    Parameters

    parentViewController

    The view controller the newly created instance is embedded into. If parentViewController conforms to SBSDKScannerViewControllerDelegate, it is automatically set as delegate.

    storage

    The image storage to persist the shot document images. Can be nil.

  • Desginated initializer. Installs the receiver as child view controller onto the parent view controllers view using its entire bounds area.

    Declaration

    Objective-C

    - (nullable instancetype)
        initWithParentViewController:
            (nonnull UIViewController *)parentViewController
                          parentView:(nullable UIView *)containerView
                        imageStorage:(nullable id<SBSDKImageStoring>)storage
               enableQRCodeDetection:(BOOL)qrCodeEnabled;

    Swift

    init?(parentViewController: UIViewController, parentView containerView: UIView?, imageStorage storage: SBSDKImageStoring?, enableQRCodeDetection qrCodeEnabled: Bool)

    Parameters

    parentViewController

    The view controller the newly created instance is embedded into. If parentViewController conforms to SBSDKScannerViewControllerDelegate, it is automatically set as delegate.

    containerView

    The view the newly created instance is embedded into. If nil the parentViewControllers view is used.

    storage

    The image storage to persist the shot document images. Can be nil.

    qrCodeEnabled

    Whether you are interested in QR code detection or not.

  • Captures a still image manually and calls the delegate methods.

    Declaration

    Objective-C

    - (BOOL)captureStillImage;

    Swift

    func captureStillImage() -> Bool

    Return Value

    YES, if the capture process has been initiated successfully. NO otherwise. Note: NO is returned if the device is currently capturing another image or if the camera session is not yet setup or broken.

  • Simulates capturing a still image manually and calls the delegate methods.

    Declaration

    Objective-C

    - (BOOL)simulateCaptureWithImage:(nullable UIImage *)image;

    Swift

    func simulateCapture(with image: UIImage?) -> Bool

    Parameters

    image

    The image that is being treated as the original image from camera.

    Return Value

    YES, if the capture process has been initiated successfully. NO otherwise. Note: NO is returned if the device is currently capturing another image or the image is nil.

  • Returns the time interval since the device has moved physically.

    Declaration

    Objective-C

    - (NSTimeInterval)timeSinceLastMotion;

    Swift

    func timeSinceLastMotion() -> TimeInterval
  • Returns the time interval since the last successful detection of a polygon.

    Declaration

    Objective-C

    - (NSTimeInterval)timeSinceLastDetectedPolygon;

    Swift

    func timeSinceLastDetectedPolygon() -> TimeInterval