Camera

Defined in framework ScanditDataCaptureCore

SDCTorchState

Added in version 6.0.0

Possible values for the torch state.

SDCTorchStateOn

Added in version 6.0.0

Value to indicate that the torch is turned on.

SDCTorchStateOff

Added in version 6.0.0

Value to indicate that the torch is turned off.

SDCTorchStateAuto

Added in version 6.3.0

Value to indicate that the torch is managed automatically. The torch is turned on or off based on the available illumination.

Note

This is an experimental feature. This functionality may or may not work for your use case or may be removed in future version of this software.

SDCTorchListener
@protocol SDCTorchListener <NSObject>

Added in version 6.3.0

Interface definition for a callback to be invoked when the SDCTorchState of a SDCCamera changes.

- didChangeTorchToState:
- (void)didChangeTorchToState:(SDCTorchState)torchState

Added in version 6.3.0

Called when SDCTorchState changed.

SDCMacroModeListener
@protocol SDCMacroModeListener <NSObject>

Added in version 6.17.0

Interface definition for a callback to be invoked when the SDCMacroMode of a SDCCamera changes.

- didChangeMacroMode:
- (void)didChangeMacroMode:(SDCMacroMode)macroMode

Added in version 6.17.0

Called when SDCMacroMode changed.

SDCCamera
@interface SDCCamera : NSObject <SDCFrameSource>

Added in version 6.0.0

Gives access to the built-in camera on iOS. It implements the SDCFrameSource protocol, and, as such can be set as the frame source for the SDCDataCaptureContext.

Instances of this class are created through one of the factory methods defaultCamera, or cameraAtPosition:.

The camera is started by changing the desired state to SDCFrameSourceStateOn.

By default, the resolution of captured frames as well as auto-focus and exposure settings are chosen such that they work best for a variety of use cases. To fine-tune recognition, the camera settings can be changed through applying new camera settings.

position
@property (nonatomic, readonly) SDCCameraPosition position

Added in version 6.0.0

The direction that the camera faces.

defaultCamera
@property (class, nonatomic, nullable, readonly) SDCCamera *defaultCamera

Added in version 6.0.0

Gets the default camera of the device. This method is identical to calling cameraAtPosition: repeatedly, first with SDCCameraPositionWorldFacing, then with SDCCameraPositionUserFacing followed by SDCCameraPositionUnspecified, stopping after the first of these calls returns a non-nil instance.

See cameraAtPosition: for a more detailed description of the method behavior.

sparkScanCamera
@property (class, nonatomic, nullable, readonly) SDCCamera *sparkScanCamera

Added in version 6.8.0

Gets the camera to be used with SDCSparkScan. It returns nil if the device does not have an ultra wide camera or if iOS/iPadOS is not at least version 13.0.

Deprecated since version 6.17.0: With the release of SparkScan we deprecated the standalone sparkScan camera.

isMacroModeAvailable
@property (class, nonatomic, readonly) BOOL isMacroModeAvailable

Added in version 6.17.0

Returns whether macro mode is available for the current device. See SDCMacroMode for details.

+ cameraAtPosition:
+ (nullable SDCCamera *)cameraAtPosition:(SDCCameraPosition)position

Added in version 6.0.0

Retrieves the camera instance of the first camera at the provided position. In case the system does not have a camera at the provided position, nil is returned.

When this method is called multiple times with the same argument, the same SDCCamera instance is returned. The SDCFrameSource.currentState of the camera as well as the settings depend on previous invocations. For example, if the camera is currently in use and is active, the camera’s SDCFrameSource.currentState will be SDCFrameSourceStateOn. The only guarantee about the state and settings is that when instance is initially created, the SDCFrameSource.currentState is SDCFrameSourceStateOff and has the default SDCCameraSettings.

Important

In case parts of your app use custom camera settings and others use the default settings, make sure to reset the camera to use the default settings when you need them by passing the default camera settings to applySettings:completionHandler: to ensure that you don’t have any other settings when you’d expect the defaults to be active.

The camera object is returned if present, regardless whether the application has permissions to use it or not.

+ cameraAtPosition:settings:
+ (nullable SDCCamera *)cameraAtPosition:(SDCCameraPosition)position
                                settings:(nullable SDCCameraSettings *)settings

Added in version 6.15.0

This method is identical to calling cameraAtPosition: and then applySettings:completionHandler: consecutively.

+ cameraFromJSONString:error:
+ (nullable instancetype)cameraFromJSONString:(nonnull NSString *)JSONString
                                        error:(NSError **)error

Added in version 6.0.0

Constructs a new camera with the provided JSON serialization. See Serialization for details.

- switchToDesiredState:completionHandler:
- (void)switchToDesiredState:(SDCFrameSourceState)state
           completionHandler:(nullable void (^)(BOOL))completionHandler

Added in version 6.0.0

Implemented from SDCFrameSource. See SDCFrameSource.switchToDesiredState:completionHandler:.

- switchToDesiredState:
- (void)switchToDesiredState:(SDCFrameSourceState)state

Added in version 6.0.0

Convenience method for SDCFrameSource.switchToDesiredState:completionHandler:: it is the same as calling switchToDesiredState:completionHandler: with the second argument set to nil.

- applySettings:completionHandler:
- (void)applySettings:(nonnull SDCCameraSettings *)settings
    completionHandler:(nullable void (^)(void))completionHandler

Added in version 6.0.0

Applies the camera settings to the camera. The task will complete when the settings have been applied and the camera has switched to use the new settings. If the camera is currently in SDCFrameSourceStateOff state, the task will complete immediately. If, on the other hand, the camera is currently in SDCFrameSourceStateOn state, the settings will be modified on the fly.

isTorchAvailable
@property (nonatomic, readonly) BOOL isTorchAvailable

Added in version 6.0.0

Whether the torch is available for the given camera.

desiredTorchState
@property (nonatomic, assign) SDCTorchState desiredTorchState

Added in version 6.0.0

The desired torch state for this camera. By default, the torch state is SDCTorchStateOff. When setting the desired torch state to SDCTorchStateOn, the torch will be on as long as the camera is running (the camera’s state is SDCFrameSourceStateOn) and off otherwise.

When setting the desired torch state to SDCTorchStateAuto, the torch is turned on or off based on the available illumination.

When setting the desired torch state for a camera that does not have a torch (see isTorchAvailable), this call has no effect.

- addTorchListener:
- (void)addTorchListener:(nonnull id<SDCTorchListener>)listener

Added in version 6.3.0

Add a listener that will be called when SDCTorchState of the camera changes.

- removeTorchListener:
- (void)removeTorchListener:(nonnull id<SDCTorchListener>)listener

Added in version 6.3.0

Remove a listener for SDCTorchState changes.

- addMacroModeListener:
- (void)addMacroModeListener:(nonnull id<SDCMacroModeListener>)listener

Added in version 6.17.0

Add a listener that will be called when SDCMacroMode of the camera changes.

- removeMacroModeListener:
- (void)removeMacroModeListener:(nonnull id<SDCMacroModeListener>)listener

Added in version 6.17.0

Remove a listener for SDCMacroMode changes.

- updateFromJSONString:error:
- (BOOL)updateFromJSONString:(nonnull NSString *)JSONString
                       error:(NSError **)error

Added in version 6.0.0

Updates the camera according to a JSON serialization. See Serialization for details.

NSStringFromCameraPosition(cameraPosition)
NSString *_Nonnull NSStringFromCameraPosition(SDCCameraPosition cameraPosition)

Added in version 6.1.0

SDCCameraPositionFromJSONString(JSONString, cameraPosition)
BOOL SDCCameraPositionFromJSONString(NSString *_Nonnull JSONString, SDCCameraPosition *_Nonnull cameraPosition)

Added in version 6.1.0

NSStringFromTorchState(torchState)
NSString *_Nonnull NSStringFromTorchState(SDCTorchState torchState)

Added in version 6.1.0

SDCTorchStateFromJSONString(JSONString, torchState)
BOOL SDCTorchStateFromJSONString(NSString *_Nonnull JSONString, SDCTorchState *_Nonnull torchState)

Added in version 6.1.0