Camera
Defined in namespace Scandit.DataCapture.Core.Source
- TorchState
Added in version 6.2.0
Possible values for the torch state.
- On
Added in version 6.2.0
Value to indicate that the torch is turned on.
- Off
Added in version 6.2.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.
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.
- ITorchListener
interface ITorchListener
Added in version 6.3.0
Interface definition for a callback to be invoked when the TorchState of a Camera changes.
- OnTorchStateChanged()
void
OnTorchStateChanged(TorchState state)Added in version 6.3.0
Called when TorchState changed.
- TorchEventArgs
class TorchEventArgs : EventArgs
Added in version 6.12.0
Provides data for Camera.TorchStateChanged event.
- TorchEventArgs()
TorchEventArgs(TorchState state)
Added in version 6.12.0
- State
TorchState State { get; }
Added in version 6.12.0
- Camera
class Camera : IFrameSource
Added in version 6.2.0
Gives access to the built-in camera on Xamarin.iOS. It implements the IFrameSource 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 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
FrameSourceState DesiredState { get; }
Added in version 6.2.0
Implemented from IFrameSource. See IFrameSource.DesiredState.
- CurrentState
FrameSourceState CurrentState { get; }
Added in version 6.2.0
Implemented from IFrameSource. See IFrameSource.CurrentState.
- Position
CameraPosition Position { get; }
Added in version 6.2.0
The direction that the camera faces.
- AddListener()
void
AddListener(IFrameSourceListener listener)Added in version 6.2.0
Implemented from IFrameSource. See IFrameSource.AddListener().
- RemoveListener()
void
RemoveListener(IFrameSourceListener listener)Added in version 6.2.0
Implemented from IFrameSource. See IFrameSource.RemoveListener().
- GetDefaultCamera()
static Camera GetDefaultCamera()
Added in version 6.2.0
Gets the default camera of the device. This method is identical to calling GetCamera() 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 GetCamera() for a more detailed description of the method behavior.
- GetCamera()
static Camera GetCamera(CameraPosition position)
Added in version 6.2.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 IFrameSource.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 IFrameSource.CurrentState will be FrameSourceState.On. The only guarantee about the state and settings is that when instance is initially created, the IFrameSource.CurrentState is FrameSourceState.Off and has the default CameraSettings.
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 ApplySettingsAsync() 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.
- FromJson()
static Camera FromJson(
string
jsonData)Added in version 6.3.0
Constructs a new camera with the provided JSON serialization.
- SwitchToDesiredState()
void
SwitchToDesiredState(FrameSourceState state, Action<bool
> completionHandler)Added in version 6.2.0
Implemented from IFrameSource. See IFrameSource.SwitchToDesiredState().
- SwitchToDesiredStateAsync()
Task<
bool
> SwitchToDesiredStateAsync(FrameSourceState state)Added in version 6.2.0
Convenience method for IFrameSource.SwitchToDesiredState(): it is the same as calling SwitchToDesiredState() with the second argument set to null.
- ApplySettingsAsync()
Task ApplySettingsAsync(CameraSettings settings)
Added in version 6.2.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.
- TorchAvailable
bool
TorchAvailable { get; }Added in version 6.2.0
Whether the torch is available for the given camera.
- DesiredTorchState
TorchState DesiredTorchState { get;set; }
Added in version 6.2.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 to TorchState.Auto, 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 TorchAvailable), this call has no effect.
- AddTorchListener()
void
AddTorchListener(ITorchListener listener)Added in version 6.3.0
Add a listener that will be called when TorchState of the camera changes.
- RemoveTorchListener()
void
RemoveTorchListener(ITorchListener listener)Added in version 6.3.0
Remove a listener for TorchState changes.
- UpdateFromJson()
void
UpdateFromJson(string
jsonData)Added in version 6.3.0
Updates the camera according to a JSON serialization.
- FrameOutput
event EventHandler<FrameOutputEventArgs> FrameOutput
Added in version 6.12.0
Occurs when a new frame is available. Consumers of this frame source can subscribe to this event to receive the frames produced by the frame source.
- StateChanged
event EventHandler<FrameSourceStateChangedEventArgs> StateChanged
Added in version 6.12.0
Occurs when frame source state changed.
- TorchStateChanged
event EventHandler<TorchEventArgs> TorchStateChanged
Added in version 6.12.0
Occurs when torch state changed.