SBSDKCameraSession

@interface SBSDKCameraSession : NSObject

An easy-to-use wrapper around the AVFoundations video capture session. Sets up and configures the camera device and the preview layer. Provides functionality to capture still images.

  • The preview layer that the camera device uses to ouput the current video frames. Can be added to any superlayer.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nonnull)
        AVCaptureVideoPreviewLayer *previewLayer;

    Swift

    var previewLayer: AVCaptureVideoPreviewLayer { get }
  • Sets or gets the current video orientation.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        AVCaptureVideoOrientation videoOrientation;

    Swift

    var videoOrientation: AVCaptureVideoOrientation { get set }
  • The delegate object for camera output. Its receives the video frames, still image captures and meta data capture, like QR code. Delegates can implement all functions from AVCaptureVideoDataOutputSampleBufferDelegate and AVCaptureMetadataOutputObjectsDelegate protocols.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<SBSDKCameraSessionDelegate>
        videoDelegate;

    Swift

    weak var videoDelegate: SBSDKCameraSessionDelegate? { get set }
  • Returns YES if the camera is currenty in the process of taking a still image, NO otherwise.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL isCapturingStillImage;

    Swift

    var isCapturingStillImage: Bool { get }
  • Returns YES if the camera device has a torch light and the torch light is available.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL torchLightAvailable;

    Swift

    var torchLightAvailable: Bool { get }
  • Turns the torch light on or off.

    Declaration

    Objective-C

    @property (getter=isTorchLightEnabled, assign, readwrite, nonatomic)
        BOOL torchLightEnabled;

    Swift

    var isTorchLightEnabled: Bool { get set }
  • A block being executed when the torch light status changes (mode or availability).

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) void (^)(void)
        updateTorchlightBlock;

    Swift

    var updateTorchlightBlock: (() -> Void)? { get set }
  • The AVCaptureSession object.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) AVCaptureSession *captureSession;

    Swift

    var captureSession: AVCaptureSession? { get }
  • Returns the current cameras exposure settings.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable)
        SBSDKCameraExposureSettings *exposureSettings;

    Swift

    var exposureSettings: SBSDKCameraExposureSettings? { get }
  • The designated initializer of the class. Does not start the capture session.

    Declaration

    Objective-C

    - (nonnull instancetype)initForFeature:(dooFeature)feature;

    Swift

    init(for feature: dooFeature)

    Parameters

    feature

    The feature you want to use the camera for. Relevant features are Document Detection, Payform Detection and QR Codes.

    Return Value

    Newly created and configured instance.

  • Extended initializer of the class. Does not start the capture session.

    Declaration

    Objective-C

    - (nullable instancetype)initForFeature:(dooFeature)feature
                                 withPreset:(AVCaptureSessionPreset _Nonnull)preset;

    Swift

    init?(for feature: dooFeature, withPreset preset: AVCaptureSession.Preset)

    Parameters

    feature

    The feature you want to use the camera for.

    preset

    The camera session preset the receiver wants to use.

    Return Value

    Newly created and configured instance or nil, if preset is not supported or setup failed.

  • Starts the camera capture session. Does nothing if the session is already running.

    Declaration

    Objective-C

    - (void)startSession;

    Swift

    func start()
  • Stops the camera capture session. Does nothing if the session is already stopped.

    Declaration

    Objective-C

    - (void)stopSession;

    Swift

    func stop()
  • Returns YES if the camera session has already been started, NO otherwise.

    Declaration

    Objective-C

    - (BOOL)isSessionRunning;

    Swift

    func isSessionRunning() -> Bool
  • Pauses the detection of documents and QR codes.

    Declaration

    Objective-C

    - (void)pauseDetection;

    Swift

    func pauseDetection()
  • Resumes the detection of documents and QR codes.

    Declaration

    Objective-C

    - (void)resumeDetection;

    Swift

    func resumeDetection()
  • Returns YES, if detection is paused, NO otherwise.

    Declaration

    Objective-C

    - (BOOL)isDetectionPaused;

    Swift

    func isDetectionPaused() -> Bool
  • Captures a still image asynchronously and passes the CMSampleBufferRef and if needed an error to the completion handler. The CMSampleBufferRef can be converted to any image format/object like UIImage.

    Declaration

    Objective-C

    - (void)captureStillImageWithCompletionHandler:
        (nullable void (^)(CMSampleBufferRef _Nullable,
                           NSError *_Nullable))completion;

    Swift

    func captureStillImage(completionHandler completion: ((CMSampleBuffer?, Error?) -> Void)? = nil)

    Parameters

    completion

    The completion handler that is called when the still image has been captured.

  • 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 (^)(NSData *_Nullable, NSError *_Nullable))completion;

    Swift

    func captureJPEGStillImage(completionHandler completion: ((Data?, Error?) -> Void)? = nil)

    Parameters

    completion

    The completion handler that is called when the still image has been captured.

  • Returns YES, if the camera is currently adjusting autofocus, exposure or white balance, NO otherwise.

    Declaration

    Objective-C

    - (BOOL)isCameraAdjusting;

    Swift

    func isCameraAdjusting() -> Bool