Table of Contents

Class RecognitionView

Namespace
CapCognition.Maui.Views
Assembly
CapCognition.Maui.dll
public class RecognitionView : BaseView, INotifyPropertyChanged, IDynamicResourceHandler, INameScope, IEffectControlProvider, IToolTipElement, IContextFlyoutElement, INavigationProxy, IAnimatable, IViewController, IVisualElementController, IElementController, IGestureController, IGestureRecognizers, IPropertyMapperView, IHotReloadableView, IReplaceableView, IBindableLayout, IPaddingElement, IVisualTreeElement, IGridLayout, ILayout, IView, IElement, ITransform, IContainer, IList<IView>, ICollection<IView>, IEnumerable<IView>, IEnumerable, ISafeAreaView, IPadding, ICrossPlatformLayout, ICameraControlledView, IRecognitionControlledView
Inheritance
RecognitionView
Implements
Inherited Members

Constructors

RecognitionView()

public RecognitionView()

Fields

IsRecognizingProperty

public static readonly BindableProperty IsRecognizingProperty

Field Value

BindableProperty

IsRecognizingPropertyKey

public static readonly BindablePropertyKey IsRecognizingPropertyKey

Field Value

BindablePropertyKey

Properties

IsRecognizing

public bool IsRecognizing { get; }

Property Value

bool

Options

The recognition options for the processors that are set for this view. Each option represent an image processor.

public IEnumerable<RecognitionOptions> Options { get; }

Property Value

IEnumerable<RecognitionOptions>

Methods

AddOption(RecognitionOptions)

Add a recognition option of an image processor to the view. The image processors of these options are executed in the order they are added. Note: An option and therefore an image processor can only be added once to the view. Adding the same option/processor twice will throw an exception.

public void AddOption(RecognitionOptions options)

Parameters

options RecognitionOptions

Exceptions

ArgumentException

CloseCamera()

Close the camera and stop the preview and running capture session.

public void CloseCamera()

GetOption<T>()

Returns the option of the specified type if it exists in the options list.

public T? GetOption<T>() where T : RecognitionOptions

Returns

T

Type Parameters

T

OnHandlerChanged()

When overridden in a derived class, should raise the HandlerChanged event.

protected override void OnHandlerChanged()

Remarks

It is the implementor's responsibility to raise the HandlerChanged event.

OnRecognitionResult(RecognitionResult?, SKBitmap)

public void OnRecognitionResult(RecognitionResult? result, SKBitmap bitmap)

Parameters

result RecognitionResult
bitmap SKBitmap

OpenCamera()

Open the camera and start the preview. The camera must be opened before any other operation can be performed.

public bool OpenCamera()

Returns

bool

True if successfully opened synchronously.If false, wait for CameraOpened event

RemoveOption(RecognitionOptions)

Remove a recognition option/image processor from the view.

public void RemoveOption(RecognitionOptions options)

Parameters

options RecognitionOptions

SetTorch(bool)

Set the torch on or off.

public override void SetTorch(bool on)

Parameters

on bool

SingleRecognition()

Take a single picture and process it with the recognition processors. Note: The recognition processors are called in the order they are added to the view and are executed sequentially. The caller owns the returned Image and must dispose it after use; event handlers borrow it.

public RecognitionImageResult? SingleRecognition()

Returns

RecognitionImageResult

SingleRecognitionAsync(CancellationToken)

Take a single picture and process it with the recognition processors. Note: The recognition processors are called in the order they are added to the view and are executed sequentially. The caller owns the returned Image and must dispose it after use; event handlers borrow it.

public Task<RecognitionImageResult?> SingleRecognitionAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<RecognitionImageResult>

The recognized results

StartContinuousRecognition(bool)

Start the continuous recognition. The recognition processors are called in the order they are added when the parallel processing flag is set to false otherwise they are executed parallel. Note: when the parallel processing flag is set to true the recognition processors are executed in parallel so

  • the order of the results is not guaranteed
  • the RecognitionResultEvt delivers the result as soon as they are available
  • the RecognitionExecutedEvt may be called in a different thread context than the main thread or calling thread
public bool StartContinuousRecognition(bool useParallelProcessing = true)

Parameters

useParallelProcessing bool

Returns

bool

True if the continuous retrieval started successful

StopContinuousRecognition()

Stops the continuous recognition.

public bool StopContinuousRecognition()

Returns

bool

True if the continuous retrieval stopped successful

Terminate()

Terminate the camera and release all resources. The camera can not be opened again after this call. The view has to be created again before the camera can be opened.

public void Terminate()

Events

InitializedEvt

public event Action? InitializedEvt

Event Type

Action

RecognitionExecutedEvt

Event that is raised when a picture is taken and processed by the recognition processors. Note: The result list can be empty when no processor found any result.

public event RecognitionView.ImageRecognizedDelegate? RecognitionExecutedEvt

Event Type

RecognitionView.ImageRecognizedDelegate

RecognitionResultEvt

Event that is raised when a picture is taken and processed by the recognition processors and at least one result is available.

public event RecognitionView.ImageRecognitionResultDelegate? RecognitionResultEvt

Event Type

RecognitionView.ImageRecognitionResultDelegate