SBSDKBaseScannerViewController
@interface SBSDKBaseScannerViewController : UIViewController
A highly customizable camera view controller that delivers a basic camera functionality along with video frame extraction and preprocessing, orientation correction and still image capturing.
Additionally you can opt-in several features using the SBSDKBaseScannerXXXConfiguration classes, e.g. zooming, energy management and view finder.
This class provides functions to be used and overwritten by subclasses to implement different detectors and recognizers.
-
Sets or gets the used camera device. Can be used to toggle between the front and back cameras, tele and wide lens.
Declaration
Objective-C
@property (nonatomic, strong, nonnull) SBSDKCameraDevice *cameraDevice;
Swift
var cameraDevice: SBSDKCameraDevice { get set }
-
Returns YES, after the receivers viewDidAppear method was called and NO after viewWillDisappear was called.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isVisible;
Swift
var isVisible: Bool { get }
-
Returns YES, if the video light is available on the device, NO otherwise.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isFlashLightAvailable;
Swift
var isFlashLightAvailable: Bool { get }
-
Enables or disables the video light on the device.
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite, getter=isFlashLightEnabled) BOOL flashLightEnabled;
Swift
var isFlashLightEnabled: Bool { get set }
-
A block being called when the flashlight is toggled. Defaults to nil.
Declaration
Objective-C
@property (nonatomic, copy, nullable) void (^)(void) flashLightDidChangeHandler;
Swift
var flashLightDidChangeHandler: (() -> Void)? { get set }
-
A block being called when the application status was changed. Defaults to nil.
Declaration
Objective-C
@property (nonatomic, copy, nullable) void (^)(SBSDKApplicationState) applicationStateDidChangeHandler;
Swift
var applicationStateDidChangeHandler: ((SBSDKApplicationState) -> Void)? { get set }
-
A block being executed when the zoom factor has changed. The new absolute zoom factor is provided as parameter.
Declaration
Objective-C
@property (nonatomic, copy, nullable) void (^)(CGFloat) zoomFactorDidChangeHandler;
Swift
var zoomFactorDidChangeHandler: ((CGFloat) -> Void)? { get set }
-
A block being called whenever the view finder rectangle changes. Can be uses to layout UI elements with respect to the view finder position. Defaults to nil. Equals to CGRectZero, if the view finder is not active.
Declaration
Objective-C
@property (nonatomic, copy, nullable) void (^)(CGRect) viewFinderRectDidChangeHandler;
Swift
var viewFinderRectDidChangeHandler: ((CGRect) -> Void)? { get set }
-
Set to NO, if you want to stop the recognition. Set to YES otherwise.
Declaration
Objective-C
@property (atomic, assign, unsafe_unretained, readwrite, getter=isRecognitionEnabled) BOOL recognitionEnabled;
Swift
var isRecognitionEnabled: Bool { get set }
-
Whether the camera permission status is accepted or not. Readonly.
Declaration
Objective-C
@property (readonly) BOOL isCameraUsageAuthorized;
Swift
var isCameraUsageAuthorized: Bool { get }
-
Whether the receiver is currently capturing a still image or not. Readonly.
Declaration
Objective-C
@property (readonly) BOOL isCapturingStillImage;
Swift
var isCapturingStillImage: Bool { get }
-
Return YES if energy saving currently is active and the recognition runs at a very low rate. Returns NO otherwise.
Declaration
Objective-C
@property (readonly, getter=isEnergySavingActive) BOOL energySavingActive;
Swift
var isEnergySavingActive: Bool { get }
-
The current camera zoom factor: a value between 0.0 (the minimum value of the zoom range) and 1.0 (the maximum value of the zoom range).
Declaration
Objective-C
@property (nonatomic, readonly) CGFloat cameraZoomFactor;
Swift
var cameraZoomFactor: CGFloat { get }
-
The current absolute camera zoom factor: a value between 1.0x and the maximum video zoom factor of the camera device.
Declaration
Objective-C
@property (nonatomic, readonly) CGFloat cameraZoomFactorAbsolute;
Swift
var cameraZoomFactorAbsolute: CGFloat { get }
-
The time interval since the last successful recognition.
Declaration
Objective-C
@property (nonatomic, readonly) NSTimeInterval timeIntervalSinceLastSuccessfulRecognition;
Swift
var timeIntervalSinceLastSuccessfulRecognition: TimeInterval { get }
-
Returns YES, if focus lock is enabled, NO otherwise. Readonly.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isFocusLockEnabled;
Swift
var isFocusLockEnabled: Bool { get }
-
The delay of recognition after appearance in seconds. Defaults to 0 seconds.
Declaration
Objective-C
@property (nonatomic) NSTimeInterval initialScanDelay;
Swift
var initialScanDelay: TimeInterval { get set }
-
The general configuration of the receiver. Lets you customize some of the basic behavior. It is copied on setting, so mutating the configuration after setting will not change the behavior. Instead, re-configure your instance and set it again.
Declaration
Objective-C
@property (nonatomic, copy) SBSDKBaseScannerGeneralConfiguration *_Nonnull generalConfiguration;
Swift
@NSCopying var generalConfiguration: SBSDKBaseScannerGeneralConfiguration { get set }
-
The zoom configuration of the receiver. Lets you enable customize the zooming behavior. It is copied on setting, so mutating the configuration after setting will not change the behavior. Instead, re-configure your instance and set it again.
Declaration
Objective-C
@property (nonatomic, copy) SBSDKBaseScannerZoomConfiguration *_Nonnull zoomConfiguration;
Swift
@NSCopying var zoomConfiguration: SBSDKBaseScannerZoomConfiguration { get set }
-
The energy configuration of the receiver. Lets you enable and customize the energy management. It is copied on setting, so mutating the configuration after setting will not change the behavior. Instead, re-configure your instance and set it again.
Declaration
Objective-C
@property (nonatomic, copy) SBSDKBaseScannerEnergyConfiguration *_Nonnull energyConfiguration;
Swift
@NSCopying var energyConfiguration: SBSDKBaseScannerEnergyConfiguration { get set }
-
The view finder configuration of the receiver. Lets you enable and customize the view finder. It is copied on setting, so mutating the configuration after setting will not change the behavior. Instead, re-configure your instance and set it again.
Declaration
Objective-C
@property (nonatomic, copy) SBSDKBaseScannerViewFinderConfiguration *_Nonnull viewFinderConfiguration;
Swift
@NSCopying var viewFinderConfiguration: SBSDKBaseScannerViewFinderConfiguration { get set }
-
A lazily generated transparent view that can be used to put UI elements too, like user guidance hints.
Declaration
Objective-C
@property (nonatomic, strong, readonly) UIView *_Nonnull overlayView;
Swift
var overlayView: UIView { get }
-
Readonly. Returns YES, if the camera session is currently being interrupted, NO otherwise.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isSessionInterrupted;
Swift
var isSessionInterrupted: Bool { get }
-
Disables auto-focus and locks the lens at the specified lens position.
Declaration
Objective-C
- (BOOL)beginFocusLockAtLensPosition:(CGFloat)lensPosition;
Swift
func beginFocusLock(atLensPosition lensPosition: CGFloat) -> Bool
Parameters
lensPosition
The position of the lens. Values can be between 0.0f (minimum focusing distance) and 1.0f (maximum focusing distance). The value will be clamped to [0.0f, 1.0f].
Return Value
YES, if the attempt to lock the focus was successful, NO if the attempt failed or if focus lock is not available.
-
Ends the focus lock and returns to standard continuous auto-focus.
Declaration
Objective-C
- (void)endFocusLock;
Swift
func endFocusLock()
-
Sets the zoom factor to the specified value.
Declaration
Objective-C
- (void)setCameraZoomFactor:(CGFloat)zoomFactor animated:(BOOL)animated;
Swift
func setCameraZoomFactor(_ zoomFactor: CGFloat, animated: Bool)
Parameters
zoomFactor
A value between 0.0 (the minimum value of the zoom range) and 1.0 (the maximum value of the zoom range). The zoom range must be specified in the receivers zoomConfigurations zoomRange property. Values outside the (0.0 - 1.0) range will be clipped.
animated
Set to YES, if the zooming should be animated, NO otherwise.
-
Resets the zoom factor to the value 0.0: the minimum value of the zoom range specified in the receivers zoomConfigurations zoomRange property.
Declaration
Objective-C
- (void)resetZoom;
Swift
func resetZoom()
-
Manually starts energy saving mode.
Declaration
Objective-C
- (void)startEnergySaving;
Swift
func startEnergySaving()
-
Manually ends energy saving mode.
Declaration
Objective-C
- (void)endEnergySaving;
Swift
func endEnergySaving()
-
Plays standard bleep sound.
Declaration
Objective-C
- (void)playBleepSound;
Swift
func playBleepSound()
-
Captures a still image asynchronously and passes the JPEG image data as NSData and if needed an error to the completion handler.
Declaration
Objective-C
- (void)captureJPEGStillImageWithCompletionHandler: (nullable void (^)(UIImage *_Nullable, NSError *_Nullable))completion;
Swift
func captureJPEGStillImage() async throws -> UIImage
Parameters
completion
The completion handler that is called when the still image has been captured.
-
The current rect of the view finder in the coordinate system of the receivers view. If no view finder is active CGRectZero is returned.
Declaration
Objective-C
- (CGRect)currentViewFinderRect;
Swift
func currentViewFinderRect() -> CGRect
-
The current rect of the secondary view finder in the coordinate system of the receivers view. If no secondary view finder is active CGRectZero is returned.
Declaration
Objective-C
- (CGRect)currentSecondaryViewFinderRect;
Swift
func currentSecondaryViewFinderRect() -> CGRect
-
Freezes the cameras preview layer by stopping the camera session.
Declaration
Objective-C
- (void)freezeCamera;
Swift
func freezeCamera()
-
Unfreezes the previously frozen cameras preview layer by restarting the camera session.
Declaration
Objective-C
- (void)unfreezeCamera;
Swift
func unfreezeCamera()
-
Embeds the scanner controller as a child view controller of the parent view controller. The scanner controller view is added to the parent view, which must be an adjacent view of the receivers view.
Declaration
Objective-C
- (BOOL)attach:(nonnull UIViewController *)parentViewController parentView:(nonnull UIView *)containerView;
Swift
func attach(_ parentViewController: UIViewController, parentView containerView: UIView) -> Bool
Parameters
parentViewController
The UIViewController that the receiver will be embedded into.
parentView
The UIView that holds and layouts the receivers view.