Dlib FaceLandmark Detector 2.0.0
Enox Software
Loading...
Searching...
No Matches
DlibFaceLandmarkDetector.UnityUtils.Utils Class Reference

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 Awaitable< 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 Awaitable.
 
static async Task< string > getFilePathAsyncTask (string filepath, Action< string, float > progressChanged=null, Action< string, string, long > errorOccurred=null, bool refresh=false, int timeout=0, CancellationToken cancellationToken=default)
 
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 async 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)
 Asynchronously retrieves the readable path of a file in the "StreamingAssets" directory using Task.
 
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 Awaitable< 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 Awaitable.
 
static async Task< IReadOnlyList< string > > getMultipleFilePathsAsyncTask (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 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 async 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)
 Asynchronously retrieves the multiple readable paths of files in the "StreamingAssets" directory using Task.
 
static string getVersion ()
 Returns this "Dlib FaceLandmark Detector" version number.
 
static bool isDebugMode ()
 Gets the current debug mode state.
 
static bool isThrowException ()
 Gets the current exception throwing state.
 
static void setDebugMode (bool debugMode, bool throwException, Action< string > callback)
 Sets the debug mode with a callback.
 
static void setDebugMode (bool debugMode, bool throwException=false)
 Sets the debug mode.
 

Member Function Documentation

◆ getFilePath()

static string DlibFaceLandmarkDetector.UnityUtils.Utils.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 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, getFilePathAsync or getFilePathAsyncTask 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 Awaitable< string > DlibFaceLandmarkDetector.UnityUtils.Utils.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 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 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 the progress. Returns the file path and a progress value (0.0 to 1.0).
errorOccurredAn optional callback that is called when the process is error occurred. 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.

◆ getFilePathAsyncTask()

static async Task< string > DlibFaceLandmarkDetector.UnityUtils.Utils.getFilePathAsyncTask ( string filepath,
Action< string, float > progressChanged = null,
Action< string, string, long > errorOccurred = null,
bool refresh = false,
int timeout = 0,
CancellationToken cancellationToken = default )
static

◆ getFilePathCoroutine()

static IEnumerator DlibFaceLandmarkDetector.UnityUtils.Utils.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 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 the progress. Returns the file path and a progress value (0.0 to 1.0).
errorOccurredAn optional callback that is called when the process is error occurred. 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 stoped, 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 async Task< string > DlibFaceLandmarkDetector.UnityUtils.Utils.getFilePathTaskAsync ( 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 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 the progress. Returns the file path and a progress value (0.0 to 1.0).
errorOccurredAn optional callback that is called when the process is error occurred. 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.

◆ getMultipleFilePaths()

static IReadOnlyList< string > DlibFaceLandmarkDetector.UnityUtils.Utils.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 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, getFilePathAsync or getFilePathAsyncTask 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 in case of success and returns string.Empty in case of error.
Exceptions
ArgumentNullExceptionThrown if filepath is null.

◆ getMultipleFilePathsAsync()

static async Awaitable< IReadOnlyList< string > > DlibFaceLandmarkDetector.UnityUtils.Utils.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 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 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 the progress. Returns the file path and a progress value (0.0 to 1.0).
errorOccurredAn optional callback that is called when one process is error occurred. 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 filepath is null.
InvalidOperationExceptionThrown if this method is called from a non-main thread.
OperationCanceledExceptionThrown if the download operation is canceled.

◆ getMultipleFilePathsAsyncTask()

static async Task< IReadOnlyList< string > > DlibFaceLandmarkDetector.UnityUtils.Utils.getMultipleFilePathsAsyncTask ( 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

◆ getMultipleFilePathsCoroutine()

static IEnumerator DlibFaceLandmarkDetector.UnityUtils.Utils.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 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 the progress. Returns the file path and a progress value (0.0 to 1.0).
errorOccurredAn optional callback that is called when one process is error occurred. 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 stoped, the UnityWebRequest's Abort method will not be called, meaning the download will continue in the background.
Exceptions
ArgumentNullExceptionThrown if filepath is null.

◆ getMultipleFilePathsTaskAsync()

static async Task< IReadOnlyList< string > > DlibFaceLandmarkDetector.UnityUtils.Utils.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

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 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 the progress. Returns the file path and a progress value (0.0 to 1.0).
errorOccurredAn optional callback that is called when one process is error occurred. 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 filepath is null.
InvalidOperationExceptionThrown if this method is called from a non-main thread.
OperationCanceledExceptionThrown if the download operation is canceled.

◆ getVersion()

static string DlibFaceLandmarkDetector.UnityUtils.Utils.getVersion ( )
static

Returns this "Dlib FaceLandmark Detector" version number.

Returns
this "Dlib FaceLandmark Detector" version number

◆ isDebugMode()

static bool DlibFaceLandmarkDetector.UnityUtils.Utils.isDebugMode ( )
static

Gets the current debug mode state.

Returns
True if debug mode is enabled, false otherwise.

◆ isThrowException()

static bool DlibFaceLandmarkDetector.UnityUtils.Utils.isThrowException ( )
static

Gets the current exception throwing state.

Returns
True if exceptions are thrown instead of logging errors, false otherwise.

◆ setDebugMode() [1/2]

static void DlibFaceLandmarkDetector.UnityUtils.Utils.setDebugMode ( bool debugMode,
bool throwException,
Action< string > callback )
static

Sets the debug mode with a callback.

If debugMode is true, The error log of the Native side Dlib will be displayed on the Unity Editor Console.However, if throwException is true, DlibException is thrown instead of calling Debug.LogError (msg). The callback is maintained even when debug mode is turned off, allowing it to be reused when debug mode is turned on again. To clear the callback, call this method with null as the callback parameter.

Please use as follows.

{
// DlibException handling
// Publish DlibException to Debug.LogError.
Utils.setDebugMode(true, false);
// Code that causes an error.
@iverbatim
// Throw DlibException.
Utils.setDebugMode(true, true);
try
{
// Code that causes an error.
}
catch (Exception e)
{
Debug.Log("DlibException: " + e);
}
// Callback string of DlibException.
Utils.setDebugMode(true, true, (str) =>
{
Debug.Log("DlibException: " + str);
});
try
{
// Code that causes an error.
}
catch (Exception e)
{
Debug.Log("DlibException: " + e);
}
Utils.setDebugMode(false);
@endiverbatim }
static void setDebugMode(bool debugMode, bool throwException=false)
Sets the debug mode.
Definition Utils.cs:1118
Parameters
debugModeIf true, The error log of the Native side Dlib will be displayed on the Unity Editor Console.
throwExceptionIf true, DlibException is thrown instead of calling Debug.LogError (msg).
callbackCallback called when an Dlib error occurs on the Native side. The callback is maintained even when debug mode is turned off. To clear the callback, pass null as this parameter.

◆ setDebugMode() [2/2]

static void DlibFaceLandmarkDetector.UnityUtils.Utils.setDebugMode ( bool debugMode,
bool throwException = false )
static

Sets the debug mode.

If debugMode is true, The error log of the Native side Dlib will be displayed on the Unity Editor Console.However, if throwException is true, DlibException is thrown instead of calling Debug.LogError (msg).

Please use as follows.

{
// DlibException handling
// Publish DlibException to Debug.LogError.
Utils.setDebugMode(true, false);
// Code that causes an error.
@iverbatim
// Throw DlibException.
Utils.setDebugMode(true, true);
try
{
// Code that causes an error.
}
catch (Exception e)
{
Debug.Log("DlibException: " + e);
}
Utils.setDebugMode(false);
@endiverbatim }
Parameters
debugModeIf true, The error log of the Native side Dlib will be displayed on the Unity Editor Console.
throwExceptionIf true, DlibException is thrown instead of calling Debug.LogError (msg).

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