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 output the current video frames. Can be added to any superlayer.
Declaration
Objective-C
@property (nonatomic, readonly, nonnull) AVCaptureVideoPreviewLayer *previewLayer;
Swift
var previewLayer: AVCaptureVideoPreviewLayer { get }
-
Returns the video resolution of the current video output. Orientation is taken into account. Returns CGSizeZero, if the capture session is not running.
Declaration
Objective-C
@property (nonatomic, readonly) CGSize videoResolution;
Swift
var videoResolution: CGSize { get }
-
Sets or gets the current video orientation.
Declaration
Objective-C
@property (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 (nonatomic, weak, nullable) id<SBSDKCameraSessionDelegate> videoDelegate;
Swift
weak var videoDelegate: SBSDKCameraSessionDelegate? { get set }
-
Returns YES if the camera is currently in the process of taking a still image, NO otherwise.
Declaration
Objective-C
@property (nonatomic, readonly) 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 (nonatomic, readonly) BOOL torchLightAvailable;
Swift
var torchLightAvailable: Bool { get }
-
Turns the torch light on or off.
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite, getter=isTorchLightEnabled) 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 (nonatomic, copy, nullable) void (^)(void) updateTorchlightBlock;
Swift
var updateTorchlightBlock: (() -> Void)? { get set }
-
The AVCaptureSession object.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) AVCaptureSession *captureSession;
Swift
var captureSession: AVCaptureSession? { get }
-
Returns the current cameras exposure settings.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) SBSDKCameraExposureSettings *exposureSettings;
Swift
var exposureSettings: SBSDKCameraExposureSettings? { get }
-
The camera devices minimum zoom factor. Readonly.
Declaration
Objective-C
@property (nonatomic, readonly) CGFloat minZoom;
Swift
var minZoom: CGFloat { get }
-
The camera devices maximum zoom factor. Readonly.
Declaration
Objective-C
@property (nonatomic, readonly) CGFloat maxZoom;
Swift
var maxZoom: CGFloat { get }
-
Sets or gets the camera devices current zoom factor. Zooming is done without animation. If the new value exceeds the minimum or maximum value for zooming it is clamped.
Declaration
Objective-C
@property (nonatomic) CGFloat zoomValue;
Swift
var zoomValue: CGFloat { get set }
-
YES, if the camera currently is zooming, NO otherwise.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isZooming;
Swift
var isZooming: Bool { get }
-
YES, if zooming is available. No otherwise.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isZoomAvailable;
Swift
var isZoomAvailable: Bool { 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 (^)(CVPixelBufferRef _Nullable, NSError *_Nullable))completion;
Swift
func captureStillImage(completionHandler completion: ((CVPixelBuffer?, 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
-
Sets the camera devices current zoom factor. If the new value exceeds the minimum or maximum value for zooming it is clamped.
Declaration
Objective-C
- (void)setZoomValue:(CGFloat)zoomValue animated:(BOOL)animated;
Swift
func setZoomValue(_ zoomValue: CGFloat, animated: Bool)
Parameters
zoomValue
The new zoom factor to be set.
animated
If YES, the zooming is animated, otherwise the change is applied without an animation.
-
Resets the zoom factor to the minimum zoom value.
Declaration
Objective-C
- (void)resetZoomAnimated:(BOOL)animated;
Swift
func resetZoom(animated: Bool)
Parameters
animated
If YES, the zooming is animated, otherwise the change is applied without an animation.