Class Recognizer
- Namespace
- CapCognition.Net
- Assembly
- CapCognition.Net.dll
A class to handle the recognition process.
public class Recognizer : IDisposable
- Inheritance
-
Recognizer
- Implements
- Inherited Members
Constructors
Recognizer()
public Recognizer()
Properties
IsAtLeastOneProcessorFree
Checks if at least one processor is finished with processing and ready for getting a new image.
public bool IsAtLeastOneProcessorFree { get; }
Property Value
Methods
Dispose()
Disposes the recognizer and stops the processors.
public void Dispose()
DrawResults(RecognitionResult?, SKBitmap, ResultDrawingOptions[]?)
Draws the results on the given bitmap.
public void DrawResults(RecognitionResult? result, SKBitmap bitmap, RecognitionProcessorResult.ResultDrawingOptions[]? resultDrawingOptions)
Parameters
resultRecognitionResultbitmapSKBitmapresultDrawingOptionsResultDrawingOptions[]
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
PrepareProcessorsAsync(int, int, List<RecognitionOptions>)
Prepares the processors for the given capture size and options.
public Task<bool> PrepareProcessorsAsync(int captureWidth, int captureHeight, List<RecognitionOptions> options)
Parameters
captureWidthintImage capture width in pixels
captureHeightintImage capture height in pixels
optionsList<RecognitionOptions>List of recognition options
Returns
ProcessImageAsync(SKBitmap, ResultDrawingOptions[]?, bool)
Processes the given bitmap with the prepared processors in sequential processing mode. If a resultDrawingOptions is given and enabled, the result will be drawn on the bitmap.
public Task<RecognitionResult?> ProcessImageAsync(SKBitmap bitmap, RecognitionProcessorResult.ResultDrawingOptions[]? resultDrawingOptions = null, bool disableBitmapDisposal = false)
Parameters
bitmapSKBitmapBitmap to be recognized. If the resultDrawingOptions are enabled, the result will be drawn on this bitmap
resultDrawingOptionsResultDrawingOptions[]Options to define the drawing attributes. If null is given, no result drawing is applied
disableBitmapDisposalboolIf true, the bitmap will not be disposed after processing.
Returns
ProcessImageParallelAsync(SKBitmap, ResultDeliveryCallback, ResultDrawingOptions[]?, bool)
Processes the given bitmap with the prepared processors in parallel processing mode. If a resultDrawingOptions is given and enabled, the results will be drawn on each of the delivered bitmap.
public Task ProcessImageParallelAsync(SKBitmap bitmap, GraphicProcessorControl.ResultDeliveryCallback resultDeliveryCB, RecognitionProcessorResult.ResultDrawingOptions[]? resultDrawingOptions = null, bool alwaysDeliverResults = false)
Parameters
bitmapSKBitmapBitmap to be recognized. If the resultDrawingOptions are enabled, the result will be drawn on this bitmap
resultDeliveryCBGraphicProcessorControl.ResultDeliveryCallbackFor each recognized result this function is called. Please be aware that this method is called under its own thread context. Make sure you NEVER block within this function!
resultDrawingOptionsResultDrawingOptions[]Options to define the drawing attributes. If null is given, no result drawing is applied
alwaysDeliverResultsboolIndicates whether results should be delivered even if no detections are found.
Returns
StartContinuousParallelImageProcessing(ImageGrabCallback, ResultDeliveryCallback, ResultDrawingOptions[]?, bool)
Starts continuous image processing in parallel. Every processor performs for itself in its own interval. An interval always consists of grabbing an image, processing it and delivering the result.
public bool StartContinuousParallelImageProcessing(GraphicProcessorControl.ImageGrabCallback grabImageCB, GraphicProcessorControl.ResultDeliveryCallback resultDeliveryCB, RecognitionProcessorResult.ResultDrawingOptions[]? resultDrawingOptions = null, bool alwaysDeliverResults = false)
Parameters
grabImageCBGraphicProcessorControl.ImageGrabCallbackA callback that is invoked to grab or provide each image to be processed. This delegate supplies the image data for recognition.
resultDeliveryCBGraphicProcessorControl.ResultDeliveryCallbackA callback that is invoked after processing each image, receiving the processed bitmap and its recognition results. Used to handle or display the results.
resultDrawingOptionsResultDrawingOptions[]An optional array of drawing options that specifies how recognition results are rendered onto the processed images. If null, default drawing options are used.
alwaysDeliverResultsboolIndicates whether results should be delivered even if no detections are found.
Returns
- bool
true if continuous parallel image processing was successfully started; otherwise, false.
Remarks
This method enables parallel processing of images, allowing for high-throughput recognition scenarios. The method returns false if the underlying controller is not available.
Note:
This method is suitable for scenarios where multiple not result dependent processors should recognize images in parallel.
All the callbacks are invoked on their own background threads; ensure that any UI updates in the callbacks are marshaled appropriately.
Important:
Try to block as little as possible within the provided callbacks to avoid performance degradation.
StartContinuousSequentialImageProcessing(ImageGrabCallback, ResultDeliveryCallback, ResultDrawingOptions[]?, bool)
Starts continuous, sequential image processing using the specified image grab and result delivery callbacks.
public bool StartContinuousSequentialImageProcessing(GraphicProcessorControl.ImageGrabCallback grabImageCB, GraphicProcessorControl.ResultDeliveryCallback resultDeliveryCB, RecognitionProcessorResult.ResultDrawingOptions[]? resultDrawingOptions = null, bool alwaysDeliverResults = false)
Parameters
grabImageCBGraphicProcessorControl.ImageGrabCallbackA callback that is invoked to acquire each image to be processed. This callback should provide the image frame for processing and is called after the image was processed by all the processors to retrieve the next image.
resultDeliveryCBGraphicProcessorControl.ResultDeliveryCallbackA callback that is invoked after each image is processed, delivering the processed bitmap and recognition results.
resultDrawingOptionsResultDrawingOptions[]An optional array of drawing options that specifies how recognition results are rendered on the output image. If null, drawing is performed
alwaysDeliverResultsboolIndicates whether results should be delivered even if no detections are found.
Returns
- bool
true if continuous sequential image processing was successfully started; otherwise, false.
Remarks
This method starts continuous image acquisition and processing in a sequential manner. The processors are invoked on each image frame sequentially before the results are delivered. If the controller is not initialized, the method returns false and processing does not start.
Note:
This method is suitable for scenarios where a single processor is present or the recognition results are dependent on each other, so it is important that all the results belong to the same image.
All the callbacks are invoked on their own background threads; ensure that any UI updates in the callbacks are marshaled appropriately.
Important:
Try to block as little as possible within the provided callbacks to avoid performance degradation.
StopContinuousImageProcessing()
Stops the ongoing continuous image processing operation, if one is currently active.
public bool StopContinuousImageProcessing()
Returns
- bool
true if the continuous image processing was successfully stopped; otherwise, false.
Remarks
Call this method to halt continuous image processing that was previously started. If no processing is active, or if the controller is unavailable, the method returns false.
StopProcessors()
Stops the processors and unprepares the recognizer.
public bool StopProcessors()