OpenCV for Unity 3.0.3
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/4.13.0/index.html ) for the details of the argument of the method.
Loading...
Searching...
No Matches
OpenCVForUnity.UnityIntegration.Runner.MatSingleFlightSyncAsyncRunner Class Referencesealed

SingleFlightSyncAsyncRunner<TInput,TResult> specialized for OpenCV Mat inputs and outputs. The generic type parameters of the base are both Mat. Async input snapshots use copyTo into an internal buffer before asyncWork runs. More...

Public Member Functions

 MatSingleFlightSyncAsyncRunner (bool useAsyncWork, CancellationToken asyncWorkCancellationToken=default, Func< Task > disposeAsyncAfterWorkTask=null)
 Initializes a new runner. Only SingleFlightSyncAsyncRunner<Mat,Mat>.DisposeAsync runs disposeAsyncAfterWorkTask ; SingleFlightSyncAsyncRunner<Mat,Mat>.Dispose does not.
 
void SubmitWork (Mat input, Func< Mat, Mat > syncWork, Func< Mat, Task< Mat > > asyncWork)
 Submits a single image; wraps Mat results as a one-element array for the base runner.
 
void SubmitWork (Mat input, Func< Mat, Mat[]> syncWork, Func< Mat, Task< Mat[]> > asyncWork)
 Submits a single image by delegating to the Mat[] overload (length 1). Reuses an internal one-element scratch to avoid per-frame array allocation.
 
bool TryGetLatestResult (out Mat result)
 Returns the single output Mat only when the latest buffer has length exactly one and that element is non-null. Whether the Mat is empty is for the caller to decide. If the latest results have two or more mats, returns false.
 
- Public Member Functions inherited from OpenCVForUnity.UnityIntegration.Runner.SingleFlightSyncAsyncRunner< Mat, Mat >
void Cancel ()
 
void Dispose ()
 Cancels in-flight work, clears the task reference without awaiting, and releases latest and async buffers. Does not call disposeAsyncAfterWorkTask.
 
async ValueTask DisposeAsync ()
 Cancels, awaits the in-flight Task, then awaits the optional disposeAsyncAfterWorkTask callback, then releases state.
 
void SubmitWork (TInput[] inputs, Func< TInput[], TResult[]> syncWork, Func< TInput[], Task< TResult[]> > asyncWork)
 Submits inputs for work: syncWork on the caller when UseAsyncWork is false, or a single in-flight asyncWork when true. When true, CopyInputsForAsync is used before asyncWork. syncWork receives inputs as passed in.
 
bool TryGetLatestResult (out TResult[] results)
 Tries to return the latest successful result array. Deriving types can tighten validation via ValidateLatestForTryGet.
 

Protected Member Functions

override void CopyInputsForAsync (Mat[] source, Mat[] destination)
 
override bool ValidateLatestForTryGet (Mat[] latest)
 Rejects latest when any element is null. Empty Mat values are not filtered here; callers use empty() or other checks as needed.
 
- Protected Member Functions inherited from OpenCVForUnity.UnityIntegration.Runner.SingleFlightSyncAsyncRunner< Mat, Mat >
 SingleFlightSyncAsyncRunner (bool useAsyncWork, CancellationToken asyncWorkCancellationToken=default, Func< Task > disposeAsyncAfterWorkTask=null)
 Initializes a new runner. Only DisposeAsync runs disposeAsyncAfterWorkTask ; Dispose does not.
 
void CopyInputsForAsync (TInput[] source, TInput[] destination)
 Snapshots source into destination (async path only). The arrays are the same length; buffer allocation is handled by EnsureAsyncInputBuffer / overrides.
 
virtual void EnsureAsyncInputBuffer (int requiredLength)
 Ensures the internal buffer used for async input snapshots has length requiredLength .
 
virtual void ReleaseAsyncInputBuffers ()
 Releases per-element resources held in EnsureAsyncInputBuffer (e.g. OpenCV Mat slots in a derived type).
 
virtual void ReleaseSingleResult (TResult result)
 Disposes a single result element. Default: IDisposable when implemented.
 
virtual bool ValidateLatestForTryGet (TResult[] latest)
 Optional extra checks for TryGetLatestResult. The default is true.
 

Additional Inherited Members

- Properties inherited from OpenCVForUnity.UnityIntegration.Runner.SingleFlightSyncAsyncRunner< Mat, Mat >
CancellationToken InFlightAsyncWorkCancellationToken [get]
 Cancellation token produced by linking the constructor cancellation token with the runner local cancellation token while an asynchronous asyncWork delegate is executing. Outside that window (including the synchronous path), this is default.
 
bool IsWorkInFlight [get]
 true while a previously started asynchronous Task is still in progress (not yet completed, faulted, or canceled). When true, SubmitWork will not start new work.
 
bool UseAsyncWork [get, set]
 When true, at most one async task runs; a new one starts only when the previous task has completed. When false, SubmitWork runs syncWork on the caller thread (after any still-running asynchronous task from a prior async mode has finished; see IsWorkInFlight and SubmitWork remarks).
 
- Events inherited from OpenCVForUnity.UnityIntegration.Runner.SingleFlightSyncAsyncRunner< Mat, Mat >
Action< WorkCompletion< TResult > > WorkCompleted
 Occurs when a submitted work unit completes (success, cancellation, or fault), on the thread that completed the operation.
 

Detailed Description

SingleFlightSyncAsyncRunner<TInput,TResult> specialized for OpenCV Mat inputs and outputs. The generic type parameters of the base are both Mat. Async input snapshots use copyTo into an internal buffer before asyncWork runs.

Constructor & Destructor Documentation

◆ MatSingleFlightSyncAsyncRunner()

OpenCVForUnity.UnityIntegration.Runner.MatSingleFlightSyncAsyncRunner.MatSingleFlightSyncAsyncRunner ( bool useAsyncWork,
CancellationToken asyncWorkCancellationToken = default,
Func< Task > disposeAsyncAfterWorkTask = null )

Initializes a new runner. Only SingleFlightSyncAsyncRunner<Mat,Mat>.DisposeAsync runs disposeAsyncAfterWorkTask ; SingleFlightSyncAsyncRunner<Mat,Mat>.Dispose does not.

Parameters
useAsyncWorkInitial async (single in-flight) mode.
asyncWorkCancellationTokenHost lifetime token combined with the runner local token for async work.
disposeAsyncAfterWorkTaskOptional hook after the in-flight task (e.g. worker WaitForCompletionTaskAsync).

Member Function Documentation

◆ CopyInputsForAsync()

override void OpenCVForUnity.UnityIntegration.Runner.MatSingleFlightSyncAsyncRunner.CopyInputsForAsync ( Mat[] source,
Mat[] destination )
protected

◆ SubmitWork() [1/2]

void OpenCVForUnity.UnityIntegration.Runner.MatSingleFlightSyncAsyncRunner.SubmitWork ( Mat input,
Func< Mat, Mat > syncWork,
Func< Mat, Task< Mat > > asyncWork )

Submits a single image; wraps Mat results as a one-element array for the base runner.

◆ SubmitWork() [2/2]

void OpenCVForUnity.UnityIntegration.Runner.MatSingleFlightSyncAsyncRunner.SubmitWork ( Mat input,
Func< Mat, Mat[]> syncWork,
Func< Mat, Task< Mat[]> > asyncWork )

Submits a single image by delegating to the Mat[] overload (length 1). Reuses an internal one-element scratch to avoid per-frame array allocation.

◆ TryGetLatestResult()

bool OpenCVForUnity.UnityIntegration.Runner.MatSingleFlightSyncAsyncRunner.TryGetLatestResult ( out Mat result)

Returns the single output Mat only when the latest buffer has length exactly one and that element is non-null. Whether the Mat is empty is for the caller to decide. If the latest results have two or more mats, returns false.

Disposal of the latest Mat (and the underlying buffer) is this runner's responsibility: it is released when newer results replace it or when this instance is disposed. Do not call Dispose on result ; the same instance remains owned by the runner until then. result is the runner's live buffer: in-place Mat operations change the stored result. If you need to modify it, call clone() (or copyTo to your own Mat) first, then work on the copy.

◆ ValidateLatestForTryGet()

override bool OpenCVForUnity.UnityIntegration.Runner.MatSingleFlightSyncAsyncRunner.ValidateLatestForTryGet ( Mat[] latest)
protected

Rejects latest when any element is null. Empty Mat values are not filtered here; callers use empty() or other checks as needed.


The documentation for this class was generated from the following file: