OpenCV for Unity 3.0.4
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/5.0/index.html ) for the details of the argument of the method.
Loading...
Searching...
No Matches
OpenCVForUnity.UnityIntegration.OpenCVForUnityEnv Class Reference

OpenCV for Unity environment utilities. More...

Static Public Member Functions

static string GetFilePath (string filepath, bool refresh=false, int timeout=0)
 Gets the readable path of a file in the "StreamingAssets" directory.
 
static async Task< string > GetFilePathAsync (string filepath, Action< string, float > progressChanged=null, Action< string, string, long > errorOccurred=null, bool refresh=false, int timeout=0, CancellationToken cancellationToken=default)
 Asynchronously retrieves the readable path of a file in the "StreamingAssets" directory using Task.
 
static async Awaitable< string > GetFilePathAwaitableAsync (string filepath, Action< string, float > progressChanged=null, Action< string, string, long > errorOccurred=null, bool refresh=false, int timeout=0, CancellationToken cancellationToken=default)
 Asynchronously retrieves the readable path of a file in the "StreamingAssets" directory using Awaitable.
 
static IEnumerator GetFilePathCoroutine (string filepath, Action< string > completed, Action< string, float > progressChanged=null, Action< string, string, long > errorOccurred=null, bool refresh=false, int timeout=0)
 Asynchronously retrieves the readable path of a file in the "StreamingAssets" directory using Coroutine.
 
static Task< string > GetFilePathTaskAsync (string filepath, Action< string, float > progressChanged=null, Action< string, string, long > errorOccurred=null, bool refresh=false, int timeout=0, CancellationToken cancellationToken=default)
 
static IReadOnlyList< string > GetMultipleFilePaths (IReadOnlyList< string > filepaths, bool refresh=false, int timeout=0)
 Gets the multiple readable paths of a file in the "StreamingAssets" directory.
 
static async Task< IReadOnlyList< string > > GetMultipleFilePathsAsync (IReadOnlyList< string > filepaths, Action< string > completed=null, Action< string, float > progressChanged=null, Action< string, string, long > errorOccurred=null, bool refresh=false, int timeout=0, CancellationToken cancellationToken=default)
 Asynchronously retrieves the multiple readable paths of files in the "StreamingAssets" directory using Task.
 
static async Awaitable< IReadOnlyList< string > > GetMultipleFilePathsAwaitableAsync (IReadOnlyList< string > filepaths, Action< string > completed=null, Action< string, float > progressChanged=null, Action< string, string, long > errorOccurred=null, bool refresh=false, int timeout=0, CancellationToken cancellationToken=default)
 Asynchronously retrieves the multiple readable paths of files in the "StreamingAssets" directory using Awaitable.
 
static IEnumerator GetMultipleFilePathsCoroutine (IReadOnlyList< string > filepaths, Action< IReadOnlyList< string > > allCompleted, Action< string > completed=null, Action< string, float > progressChanged=null, Action< string, string, long > errorOccurred=null, bool refresh=false, int timeout=0)
 Asynchronously retrieves the multiple readable paths of files in the "StreamingAssets" directory using Coroutine.
 
static Task< IReadOnlyList< string > > GetMultipleFilePathsTaskAsync (IReadOnlyList< string > filepaths, Action< string > completed=null, Action< string, float > progressChanged=null, Action< string, string, long > errorOccurred=null, bool refresh=false, int timeout=0, CancellationToken cancellationToken=default)
 
static string GetVersion ()
 Returns this "OpenCV for Unity" version number.
 

Properties

static bool IsSentisIntegrationAvailable [get]
 Whether EnoxSoftware.OpenCVForUnity was built with Unity Sentis (Inference Engine) integration (OPENCV_SENTIS_AVAILABLE).
 
static bool IsWebCamTextureApiAvailable [get]
 Whether WebCamTexture-based SourceToMat helpers were compiled into this build (inverse of OPENCV_DONT_USE_WEBCAMTEXTURE_API).
 

Detailed Description

OpenCV for Unity environment utilities.

Member Function Documentation

◆ GetFilePath()

static string OpenCVForUnity.UnityIntegration.OpenCVForUnityEnv.GetFilePath ( string filepath,
bool refresh = false,
int timeout = 0 )
static

Gets the readable path of a file in the "StreamingAssets" directory.

Provide a relative file path based on the "StreamingAssets" directory. e.g., "foobar.txt" or "hogehoge/foobar.txt". [Android] The target file that exists in the "StreamingAssets" directory is copied to the Application.persistentDataPath directory. [WebGL] If the target file has not yet been copied to WebGL's virtual filesystem, it is necessary to use GetFilePathCoroutine, GetFilePathAwaitableAsync or GetFilePathAsync at first.

Parameters
filepathA file path relative to the "StreamingAssets" directory.
refresh[Android] If false, the file is not copied if it already exists. If true, the file is always copied.
timeout[Android] Sets the UnityWebRequest to abort after the specified number of seconds. If set to 0, no timeout is applied. The default is 0.
Returns
Returns the readable file path in case of success and returns string.Empty in case of error.
Exceptions
ArgumentNullExceptionThrown if filepath is null.

◆ GetFilePathAsync()

static async Task< string > OpenCVForUnity.UnityIntegration.OpenCVForUnityEnv.GetFilePathAsync ( string filepath,
Action< string, float > progressChanged = null,
Action< string, string, long > errorOccurred = null,
bool refresh = false,
int timeout = 0,
CancellationToken cancellationToken = default )
static

Asynchronously retrieves the readable path of a file in the "StreamingAssets" directory using Task.

Provide a relative file path based on the "StreamingAssets" directory. e.g., "foobar.txt" or "hogehoge/foobar.txt". [Android] The target file that exists in the "StreamingAssets" directory is copied to the Application.persistentDataPath directory. [WebGL] The target file in the "StreamingAssets" directory is copied to the WebGL's virtual filesystem.

Parameters
filepathA file path relative to the "StreamingAssets" directory.
progressChangedAn optional callback that is called when the process is in progress. Returns the file path and a progress value (0.0 to 1.0).
errorOccurredAn optional callback that is called when an error occurs. Returns the file path and an error string and an error response code.
refresh[Android][WebGL] If false, the file is not copied if it already exists. If true, the file is always copied.
timeout[Android][WebGL] Sets the UnityWebRequest to abort after the specified number of seconds. If set to 0, no timeout is applied. The default is 0.
cancellationTokenA cancellation token that can be used to cancel the download operation.
Returns
A task that represents the asynchronous download operation. The result is a readable file path where the downloaded file was saved, or string.Empty if the download fails.
Exceptions
ArgumentNullExceptionThrown if filepath is null.
InvalidOperationExceptionThrown if this method is called from a non-main thread.
OperationCanceledExceptionThrown if the download operation is canceled.

◆ GetFilePathAwaitableAsync()

static async Awaitable< string > OpenCVForUnity.UnityIntegration.OpenCVForUnityEnv.GetFilePathAwaitableAsync ( string filepath,
Action< string, float > progressChanged = null,
Action< string, string, long > errorOccurred = null,
bool refresh = false,
int timeout = 0,
CancellationToken cancellationToken = default )
static

Asynchronously retrieves the readable path of a file in the "StreamingAssets" directory using Awaitable.

Provide a relative file path based on the "StreamingAssets" directory. e.g., "foobar.txt" or "hogehoge/foobar.txt". [Android] The target file that exists in the "StreamingAssets" directory is copied to the Application.persistentDataPath directory. [WebGL] The target file in the "StreamingAssets" directory is copied to the WebGL's virtual filesystem.

Parameters
filepathA file path relative to the "StreamingAssets" directory.
progressChangedAn optional callback that is called when the process is in progress. Returns the file path and a progress value (0.0 to 1.0).
errorOccurredAn optional callback that is called when an error occurs. Returns the file path and an error string and an error response code.
refresh[Android][WebGL] If false, the file is not copied if it already exists. If true, the file is always copied.
timeout[Android][WebGL] Sets the UnityWebRequest to abort after the specified number of seconds. If set to 0, no timeout is applied. The default is 0.
cancellationTokenA cancellation token that can be used to cancel the download operation.
Returns
A task that represents the asynchronous download operation. The result is a readable file path where the downloaded file was saved, or string.Empty if the download fails.
Exceptions
ArgumentNullExceptionThrown if filepath is null.
InvalidOperationExceptionThrown if this method is called from a non-main thread.
OperationCanceledExceptionThrown if the download operation is canceled.

◆ GetFilePathCoroutine()

static IEnumerator OpenCVForUnity.UnityIntegration.OpenCVForUnityEnv.GetFilePathCoroutine ( string filepath,
Action< string > completed,
Action< string, float > progressChanged = null,
Action< string, string, long > errorOccurred = null,
bool refresh = false,
int timeout = 0 )
static

Asynchronously retrieves the readable path of a file in the "StreamingAssets" directory using Coroutine.

Provide a relative file path based on the "StreamingAssets" directory. e.g., "foobar.txt" or "hogehoge/foobar.txt". [Android] The target file that exists in the "StreamingAssets" directory is copied to the Application.persistentDataPath directory. [WebGL] The target file in the "StreamingAssets" directory is copied to the WebGL's virtual filesystem.

Parameters
filepathA file path relative to the "StreamingAssets" directory.
completedA callback that is called when the process is completed. Returns a readable file path in case of success and returns string.Empty in case of error.
progressChangedAn optional callback that is called when the process is in progress. Returns the file path and a progress value (0.0 to 1.0).
errorOccurredAn optional callback that is called when an error occurs. Returns the file path and an error string and an error response code.
refresh[Android][WebGL] If false, the file is not copied if it already exists. If true, the file is always copied.
timeout[Android][WebGL] Sets the UnityWebRequest to abort after the specified number of seconds. If set to 0, no timeout is applied. The default is 0.
Returns
Returns an IEnumerator object. Yielding the IEnumerator in a coroutine pauses the coroutine until the UnityWebRequest completes or encounters a system error. Note: that if the IEnumerator is externally stopped, the UnityWebRequest's Abort method will not be called, meaning the download will continue in the background.
Exceptions
ArgumentNullExceptionThrown if filepath is null.

◆ GetFilePathTaskAsync()

static Task< string > OpenCVForUnity.UnityIntegration.OpenCVForUnityEnv.GetFilePathTaskAsync ( string filepath,
Action< string, float > progressChanged = null,
Action< string, string, long > errorOccurred = null,
bool refresh = false,
int timeout = 0,
CancellationToken cancellationToken = default )
static

◆ GetMultipleFilePaths()

static IReadOnlyList< string > OpenCVForUnity.UnityIntegration.OpenCVForUnityEnv.GetMultipleFilePaths ( IReadOnlyList< string > filepaths,
bool refresh = false,
int timeout = 0 )
static

Gets the multiple readable paths of a file in the "StreamingAssets" directory.

Provide a relative file path based on the "StreamingAssets" directory. e.g., "foobar.txt" or "hogehoge/foobar.txt". [Android] The target file that exists in the "StreamingAssets" directory is copied to the Application.persistentDataPath directory. [WebGL] If the target file has not yet been copied to WebGL's virtual filesystem, it is necessary to use GetFilePathCoroutine, GetFilePathAwaitableAsync or GetFilePathAsync at first.

Parameters
filepathsThe list of file paths relative to the "StreamingAssets" directory.
refresh[Android] If false, the file is not copied if it already exists. If true, the file is always copied.
timeout[Android] Sets the UnityWebRequest to abort after the specified number of seconds. If set to 0, no timeout is applied. The default is 0.
Returns
Returns the list of readable file paths. Each entry may be string.Empty if that file could not be resolved.
Exceptions
ArgumentNullExceptionThrown if filepaths is null.

◆ GetMultipleFilePathsAsync()

static async Task< IReadOnlyList< string > > OpenCVForUnity.UnityIntegration.OpenCVForUnityEnv.GetMultipleFilePathsAsync ( IReadOnlyList< string > filepaths,
Action< string > completed = null,
Action< string, float > progressChanged = null,
Action< string, string, long > errorOccurred = null,
bool refresh = false,
int timeout = 0,
CancellationToken cancellationToken = default )
static

Asynchronously retrieves the multiple readable paths of files in the "StreamingAssets" directory using Task.

Provide a relative file path based on the "StreamingAssets" directory. e.g., "foobar.txt" or "hogehoge/foobar.txt". [Android] The target file that exists in the "StreamingAssets" directory is copied to the Application.persistentDataPath directory. [WebGL] The target file in the "StreamingAssets" directory is copied to the WebGL's virtual filesystem.

Parameters
filepathsThe list of file paths relative to the "StreamingAssets" directory.
completedAn optional callback that is called when one process is completed. Returns a readable file path in case of success and returns empty in case of error.
progressChangedAn optional callback that is called when one process is in progress. Returns the file path and a progress value (0.0 to 1.0).
errorOccurredAn optional callback that is called when an error occurs in one process. Returns the file path and an error string and an error response code.
refresh[Android][WebGL] If false, the file is not copied if it already exists. If true, the file is always copied.
timeout[Android][WebGL] Sets the UnityWebRequest to abort after the specified number of seconds. If set to 0, no timeout is applied. The default is 0.
cancellationTokenA cancellation token that can be used to cancel the download operation.
Returns
A task that represents the asynchronous download operation. The result is a list of readable file paths where the downloaded file was saved, or string.Empty if the download fails.
Exceptions
ArgumentNullExceptionThrown if filepaths is null.
InvalidOperationExceptionThrown if this method is called from a non-main thread.
OperationCanceledExceptionThrown if the download operation is canceled.

◆ GetMultipleFilePathsAwaitableAsync()

static async Awaitable< IReadOnlyList< string > > OpenCVForUnity.UnityIntegration.OpenCVForUnityEnv.GetMultipleFilePathsAwaitableAsync ( IReadOnlyList< string > filepaths,
Action< string > completed = null,
Action< string, float > progressChanged = null,
Action< string, string, long > errorOccurred = null,
bool refresh = false,
int timeout = 0,
CancellationToken cancellationToken = default )
static

Asynchronously retrieves the multiple readable paths of files in the "StreamingAssets" directory using Awaitable.

Provide a relative file path based on the "StreamingAssets" directory. e.g., "foobar.txt" or "hogehoge/foobar.txt". [Android] The target file that exists in the "StreamingAssets" directory is copied to the Application.persistentDataPath directory. [WebGL] The target file in the "StreamingAssets" directory is copied to the WebGL's virtual filesystem.

Parameters
filepathsThe list of file paths relative to the "StreamingAssets" directory.
completedAn optional callback that is called when one process is completed. Returns a readable file path in case of success and returns empty in case of error.
progressChangedAn optional callback that is called when one process is in progress. Returns the file path and a progress value (0.0 to 1.0).
errorOccurredAn optional callback that is called when an error occurs in one process. Returns the file path and an error string and an error response code.
refresh[Android][WebGL] If false, the file is not copied if it already exists. If true, the file is always copied.
timeout[Android][WebGL] Sets the UnityWebRequest to abort after the specified number of seconds. If set to 0, no timeout is applied. The default is 0.
cancellationTokenA cancellation token that can be used to cancel the download operation.
Returns
A task that represents the asynchronous download operation. The result is a list of readable file paths where the downloaded file was saved, or string.Empty if the download fails.
Exceptions
ArgumentNullExceptionThrown if filepaths is null.
InvalidOperationExceptionThrown if this method is called from a non-main thread.
OperationCanceledExceptionThrown if the download operation is canceled.

◆ GetMultipleFilePathsCoroutine()

static IEnumerator OpenCVForUnity.UnityIntegration.OpenCVForUnityEnv.GetMultipleFilePathsCoroutine ( IReadOnlyList< string > filepaths,
Action< IReadOnlyList< string > > allCompleted,
Action< string > completed = null,
Action< string, float > progressChanged = null,
Action< string, string, long > errorOccurred = null,
bool refresh = false,
int timeout = 0 )
static

Asynchronously retrieves the multiple readable paths of files in the "StreamingAssets" directory using Coroutine.

Provide a relative file path based on the "StreamingAssets" directory. e.g., "foobar.txt" or "hogehoge/foobar.txt". [Android] The target file that exists in the "StreamingAssets" directory is copied to the Application.persistentDataPath directory. [WebGL] The target file in the "StreamingAssets" directory is copied to the WebGL's virtual filesystem.

Parameters
filepathsThe list of file paths relative to the "StreamingAssets" directory.
allCompletedA callback that is called when all processes are completed. Returns a list of file paths. Returns a readable file path in case of success and returns string.Empty in case of error.
completedAn optional callback that is called when one process is completed. Returns a readable file path in case of success and returns empty in case of error.
progressChangedAn optional callback that is called when one process is in progress. Returns the file path and a progress value (0.0 to 1.0).
errorOccurredAn optional callback that is called when an error occurs in one process. Returns the file path and an error string and an error response code.
refresh[Android][WebGL] If false, the file is not copied if it already exists. If true, the file is always copied.
timeout[Android][WebGL] Sets the UnityWebRequest to abort after the specified number of seconds. If set to 0, no timeout is applied. The default is 0.
Returns
Returns an IEnumerator object. Yielding the IEnumerator in a coroutine pauses the coroutine until the UnityWebRequest completes or encounters a system error. Note: that if the IEnumerator is externally stopped, the UnityWebRequest's Abort method will not be called, meaning the download will continue in the background.
Exceptions
ArgumentNullExceptionThrown if filepaths is null.

◆ GetMultipleFilePathsTaskAsync()

static Task< IReadOnlyList< string > > OpenCVForUnity.UnityIntegration.OpenCVForUnityEnv.GetMultipleFilePathsTaskAsync ( IReadOnlyList< string > filepaths,
Action< string > completed = null,
Action< string, float > progressChanged = null,
Action< string, string, long > errorOccurred = null,
bool refresh = false,
int timeout = 0,
CancellationToken cancellationToken = default )
static

◆ GetVersion()

static string OpenCVForUnity.UnityIntegration.OpenCVForUnityEnv.GetVersion ( )
static

Returns this "OpenCV for Unity" version number.

Returns
this "OpenCV for Unity" version number

Property Documentation

◆ IsSentisIntegrationAvailable

bool OpenCVForUnity.UnityIntegration.OpenCVForUnityEnv.IsSentisIntegrationAvailable
staticget

Whether EnoxSoftware.OpenCVForUnity was built with Unity Sentis (Inference Engine) integration (OPENCV_SENTIS_AVAILABLE).

Compile-time constant for the main assembly. Other assemblies can branch on this without defining OPENCV_SENTIS_AVAILABLE themselves. Does not change at runtime; recompilation is required after enabling or disabling Sentis integration in the project.

◆ IsWebCamTextureApiAvailable

bool OpenCVForUnity.UnityIntegration.OpenCVForUnityEnv.IsWebCamTextureApiAvailable
staticget

Whether WebCamTexture-based SourceToMat helpers were compiled into this build (inverse of OPENCV_DONT_USE_WEBCAMTEXTURE_API).

Compile-time constant for the main assembly. When false, types such as WebCamTextureToMatHelper are not included in the build; callers that reference those types still require conditional compilation. Does not change at runtime.


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