Camera
Defined in package com.scandit.datacapture.core
- TorchState
Added in version 8.6.0
Possible values for the torch state.
- ON
Added in version 8.6.0
Value to indicate that the torch is turned on.
- OFF
Added in version 8.6.0
Value to indicate that the torch is turned off.
- AUTO
Added in version 8.6.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.
- TorchListener
interface TorchListenerAdded in version 8.6.0
Interface definition for a callback to be invoked when the TorchState of a Camera changes.
- onTorchStateChanged(state)
fun onTorchStateChanged(state: TorchState)
Added in version 8.6.0
Called when TorchState changed.
- MacroModeListener
interface MacroModeListenerAdded in version 8.6.0
Interface definition for a callback to be invoked when the MacroMode of a Camera changes.
- ZoomListener
interface ZoomListenerAdded in version 8.6.0
Interface definition for a callback to be invoked when the zoom level of a Camera changes.
- Camera
class Camera : FrameSource
Added in version 8.6.0
Gives access to the built-in camera on Kotlin Multiplatform. It implements the FrameSource interface and can be set as the frame source for the DataCaptureContext.
Instances of this class are created through one of the factory methods getDefaultCamera(), or getCamera().
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
val desiredState: FrameSourceState
Added in version 8.6.0
Implemented from FrameSource. See FrameSource.desiredState.
- currentState
val currentState: FrameSourceState
Added in version 8.6.0
Implemented from FrameSource. See FrameSource.currentState.
- position
val position: CameraPosition
Added in version 8.6.0
The direction that the camera faces.
- addListener(listener)
fun addListener(listener: FrameSourceListener)
Added in version 8.6.0
Implemented from FrameSource. See FrameSource.addListener().
- removeListener(listener)
fun removeListener(listener: FrameSourceListener)
Added in version 8.6.0
Implemented from FrameSource. See FrameSource.removeListener().
- getDefaultCamera()
fun Camera.getDefaultCamera(): Camera?
Added in version 8.6.0
Gets the default camera of the device. This method is identical to calling getCamera() repeatedly, first with CameraPosition.WORLD_FACING, then with CameraPosition.USER_FACING followed by CameraPosition.UNSPECIFIED, stopping after the first of these calls returns a non-null instance.
See getCamera() for a more detailed description of the method behavior.
- isMacroModeAvailable()
fun Camera.isMacroModeAvailable():
BooleanAdded in version 8.6.0
Returns whether macro mode is available for the current device. See MacroMode for details.
- getDefaultCamera(settings)
fun Camera.getDefaultCamera(settings: CameraSettings): Camera?
Added in version 8.6.0
- getCamera(position)
fun Camera.getCamera(position: CameraPosition): Camera?
Added in version 8.6.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.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 FrameSource.currentState will be FrameSourceState.ON. The only guarantee about the state and settings is that when instance is initially created, the FrameSource.currentState is FrameSourceState.OFF and has the default CameraSettings.
Important
The camera object is returned if present, regardless whether the application has permissions to use it or not.
- getCamera(position, settings)
fun Camera.getCamera(position: CameraPosition, settings: CameraSettings): Camera?
Added in version 8.6.0
- switchToDesiredState(state, callback)
fun switchToDesiredState(state: FrameSourceState, callback: ((Boolean) -> Unit)?)
Added in version 8.6.0
- applySettings(settings, callback)
fun applySettings(settings: CameraSettings, callback: (() -> Unit)?)
Added in version 8.6.0
Applies the provided CameraSettings to the camera.
- isTorchAvailable
val isTorchAvailable:
BooleanAdded in version 8.6.0
- desiredTorchState
var desiredTorchState: TorchState
Added in version 8.6.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 isTorchAvailable), this call has no effect.
- addTorchListener(listener)
fun addTorchListener(listener: TorchListener)
Added in version 8.6.0
Adds a listener that will be called when TorchState of the camera changes.
- removeTorchListener(listener)
fun removeTorchListener(listener: TorchListener)
Added in version 8.6.0
Removes a listener for TorchState changes.
- addMacroModeListener(listener)
fun addMacroModeListener(listener: MacroModeListener)
Added in version 8.6.0
Adds a listener that will be called when MacroMode of the camera changes.
- removeMacroModeListener(listener)
fun removeMacroModeListener(listener: MacroModeListener)
Added in version 8.6.0
Removes a listener for MacroMode changes.
- addZoomListener(listener)
fun addZoomListener(listener: ZoomListener)
Added in version 8.6.0
Adds a listener that will be called when the zoom level of the camera changes.
- removeZoomListener(listener)
fun removeZoomListener(listener: ZoomListener)
Added in version 8.6.0
Removes a previously added listener for zoom level changes.