Camera
Defined under the namespace Scandit.Datacapture.Core
- TorchState
Added in version 6.1.0
Possible values for the torch state.
- On
Added in version 6.1.0
Value to indicate that the torch is turned on.
- Off
Added in version 6.1.0
Value to indicate that the torch is turned off.
- Auto
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.
On Android this requires camera API 2. To make use of the automatic switch to API 2, make sure that you instantiate the camera directly with the settings instead of using Camera.applySettings().
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.
- Camera
class Camera : FrameSource
Added in version 6.1.0
Gives access to the built-in camera on Cordova. It implements the FrameSource interface, and, as such can be set as the frame source for the DataCaptureContext.
Instances of this class are created through one of the factory methods default(), or atPosition().
The camera is started by changing the desired state to FrameSourceState.On.
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.
- desiredState
get desiredState(): FrameSourceState
Added in version 6.1.0
Implemented from FrameSource. See FrameSource.desiredState.
- getCurrentState()
getCurrentState(): Promise<FrameSourceState>
Added in version 6.1.0
Implemented from FrameSource. See FrameSource.getCurrentState.
- addListener(listener)
addListener(listener: FrameSourceListener | null):
void
Added in version 6.1.0
Implemented from FrameSource. See FrameSource.addListener().
- removeListener(listener)
removeListener(listener: FrameSourceListener | null):
void
Added in version 6.1.0
Implemented from FrameSource. See FrameSource.removeListener().
- default()
static get default(): Camera | null
Added in version 6.1.0
Gets the default camera of the device. This method is identical to calling atPosition() repeatedly, first with CameraPosition.WorldFacing, then with CameraPosition.UserFacing followed by CameraPosition.Unspecified, stopping after the first of these calls returns a non-null instance.
See atPosition() for a more detailed description of the method behavior.
- withSettings(settings)
static withSettings(settings: CameraSettings): Camera | null
Added in version 6.23.0
- atPosition(cameraPosition)
static atPosition(cameraPosition: CameraPosition): Camera | null
Added in version 6.1.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, null is returned.
When this method is called multiple times with the same argument, the same Camera instance is returned. The FrameSource.getCurrentState 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 FrameSource.getCurrentState will be FrameSourceState.On. The only guarantee about the state and settings is that when instance is initially created, the FrameSource.getCurrentState is FrameSourceState.Off and has the default CameraSettings.
The camera object is returned if present, regardless whether the application has permissions to use it or not.
- asPositionWithSettings(cameraPosition, settings)
static asPositionWithSettings(cameraPosition: CameraPosition, settings: CameraSettings): Camera | null
Added in version 6.25.0
- switchToDesiredState(state)
switchToDesiredState(state: FrameSourceState): Promise<
void
>Added in version 6.1.0
Implemented from FrameSource. See FrameSource.switchToDesiredState().
- applySettings(settings)
applySettings(settings: CameraSettings): Promise<
void
>Added in version 6.1.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 FrameSourceState.Off state, the task will complete immediately. If, on the other hand, the camera is currently in FrameSourceState.On state, the settings will be modified on the fly.
- isTorchAvailable
get isTorchAvailable(): boolean
Added in version 6.1.0
Whether the torch is available for the given camera.
Android only: When the camera is off, this method always returns false. When the camera is on, it returns true for cameras that support the torch, false otherwise.
Deprecated since version 6.6.0: Replaced by getIsTorchAvailable().
- getIsTorchAvailable()
getIsTorchAvailable(): Promise<boolean>
Added in version 6.6.0
Whether the torch is available for the given camera.
Android only: When the camera is off, this method always returns false. When the camera is on, it returns true for cameras that support the torch, false otherwise.
- desiredTorchState
desiredTorchState: TorchState
Added in version 6.1.0
The desired torch state for this camera. By default, the torch state is TorchState.Off. When setting the desired torch state to TorchState.On, the torch will be on as long as the camera is running (the camera’s state is FrameSourceState.On) and off otherwise.
When setting the desired torch state for a camera that does not have a torch (see getIsTorchAvailable()), this call has no effect.