OpenCV for Unity  2.6.0
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/4.9.0/index.html ) for the details of the argument of the method.
Static Public Member Functions | List of all members
OpenCVForUnity.UnityUtils.Utils Class Reference

Static Public Member Functions

static string getVersion ()
 
static void matToTexture2D (Mat mat, Texture2D texture2D, bool flip=true, int flipCode=0, bool flipAfter=false, bool updateMipmaps=false, bool makeNoLongerReadable=false)
 
static void matToTexture2D (Mat mat, Texture2D texture2D, Color32[] pixels32Buffer, byte[] rawTextureDataBuffer=null, bool flip=true, int flipCode=0, bool flipAfter=false, bool updateMipmaps=false, bool makeNoLongerReadable=false)
 
static void fastMatToTexture2D (Mat mat, Texture2D texture2D, bool flip=true, int flipCode=0, bool flipAfter=false, bool updateMipmaps=false, bool makeNoLongerReadable=false)
 
static void texture2DToMat (Texture2D texture2D, Mat mat, bool flipAfter=true, int flipCode=0)
 
static void fastTexture2DToMat (Texture2D texture2D, Mat mat, bool flipAfter=true, int flipCode=0)
 
static void webCamTextureToMat (WebCamTexture webCamTexture, Mat mat, bool flipAfter=true, int flipCode=0)
 
static void webCamTextureToMat (WebCamTexture webCamTexture, Mat mat, Color32[] pixels32Buffer, bool flipAfter=true, int flipCode=0)
 
static void textureToTexture2D (Texture texture, Texture2D texture2D)
 
static string getFilePath (string filepath, bool refresh=false, int timeout=0)
 
static List< string > getMultipleFilePaths (IList< string > filepaths, bool refresh=false, int timeout=0)
 
static IEnumerator getFilePathAsync (string filepath, Action< string > completed, bool refresh=false, int timeout=0)
 
static IEnumerator getFilePathAsync (string filepath, Action< string > completed, Action< string, float > progressChanged, bool refresh=false, int timeout=0)
 
static IEnumerator getFilePathAsync (string filepath, Action< string > completed, Action< string, float > progressChanged, Action< string, string, long > errorOccurred, bool refresh=false, int timeout=0)
 
static IEnumerator getMultipleFilePathsAsync (IList< string > filepaths, Action< List< string >> allCompleted, bool refresh=false, int timeout=0)
 
static IEnumerator getMultipleFilePathsAsync (IList< string > filepaths, Action< List< string >> allCompleted, Action< string > completed, bool refresh=false, int timeout=0)
 
static IEnumerator getMultipleFilePathsAsync (IList< string > filepaths, Action< List< string >> allCompleted, Action< string > completed, Action< string, float > progressChanged, bool refresh=false, int timeout=0)
 
static IEnumerator getMultipleFilePathsAsync (IList< string > filepaths, Action< List< string >> allCompleted, Action< string > completed, Action< string, float > progressChanged, Action< string, string, long > errorOccurred, bool refresh=false, int timeout=0)
 
static void setDebugMode (bool debugMode, bool throwException=false, Action< string > callback=null)
 

Member Function Documentation

◆ fastMatToTexture2D()

static void OpenCVForUnity.UnityUtils.Utils.fastMatToTexture2D ( Mat  mat,
Texture2D  texture2D,
bool  flip = true,
int  flipCode = 0,
bool  flipAfter = false,
bool  updateMipmaps = false,
bool  makeNoLongerReadable = false 
)
static

Fast converts OpenCV Mat to Unity Texture2D.


This method simply copies the mat data to texture2D. Therefore, there are no restrictions on the mat's type and texture2D's format; it is faster than the matToTexture2D() method.
The Mat object and the Texture2D object must have the same width, height, and data format.
Enable the "unsafe" code if you want the conversion process to run the fastest; use NativeArray to run the conversion process several times faster with no overhead. If you want to use optimization code using NativeArray class, click the MenuItem[Tools/OpenCV for Unity/Open Setup Tools] - [Enable Use Unsafe Code] button.

Parameters
mat
texture2Dthe Texture2D object must have the same size and data format (width * height * channels) as the Mat.
flipif true, the mat is fliped before converting.
flipCodea flag to specify how to flip the array; 0 means flipping around the x-axis and positive value (for example, 1) means flipping around y-axis. Negative value (for example, -1) means flipping around both axes.
flipAfterif true, the mat is fliped after converting. If you want to use mat even after calling this method, set true.
updateMipmapswhen set to true, mipmap levels are recalculated.
makeNoLongerReadablewhen set to true, system memory copy of a texture is released.

◆ fastTexture2DToMat()

static void OpenCVForUnity.UnityUtils.Utils.fastTexture2DToMat ( Texture2D  texture2D,
Mat  mat,
bool  flipAfter = true,
int  flipCode = 0 
)
static

Fast converts Unity Texture2D to OpenCV Mat.


This method simply copies the texture2D data to mat. Therefore, there are no restrictions on the mat's type and texture2D's format; it is faster than the texture2DToMat() method.
The Texture2D object and the Mat object must have the same width, height, and data format.
Enable the "unsafe" code if you want the conversion process to run the fastest; use NativeArray to run the conversion process several times faster with no overhead. If you want to use optimization code using NativeArray class, click the MenuItem[Tools/OpenCV for Unity/Open Setup Tools] - [Enable Use Unsafe Code] button.

Parameters
texture2D
matthe Mat object must have the same size and data format (width * height * channels) as the Texture2D.
flipAfterif true, the mat is fliped after converting.
flipCodea flag to specify how to flip the array; 0 means flipping around the x-axis and positive value (for example, 1) means flipping around y-axis. Negative value (for example, -1) means flipping around both axes.

◆ getFilePath()

static string OpenCVForUnity.UnityUtils.Utils.getFilePath ( string  filepath,
bool  refresh = false,
int  timeout = 0 
)
static

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


Set a relative file path from the starting point of the "StreamingAssets" folder. e.g. "foobar.txt" or "hogehoge/foobar.txt".
[Android] The target file that exists in the "StreamingAssets" folder is copied into the folder of the Application.persistentDataPath. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
[WebGL] If the target file has not yet been copied to WebGL's virtual filesystem, you need to use getFilePathAsync() at first.

Parameters
filepatha relative file path starting from "StreamingAssets" folder.
refresh[Android] If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
timeout[Android 2017.1+] Sets UnityWebRequest to attempt to abort after the number of seconds in timeout has passed. No timeout is applied when timeout is set to 0 and this property defaults to 0.
Returns
returns a readable file path in case of success and returns empty in case of error.

◆ getFilePathAsync() [1/3]

static IEnumerator OpenCVForUnity.UnityUtils.Utils.getFilePathAsync ( string  filepath,
Action< string >  completed,
bool  refresh = false,
int  timeout = 0 
)
static

Gets the readable path of a file in the "StreamingAssets" folder by using coroutines.


Set a relative file path from the starting point of the "StreamingAssets" folder. e.g. "foobar.txt" or "hogehoge/foobar.txt".
[Android] The target file that exists in the "StreamingAssets" folder is copied into the folder of the Application.persistentDataPath. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
[WebGL] The target file in the "StreamingAssets" folder is copied to the WebGL's virtual filesystem. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.

Parameters
filepatha relative file path starting from the "StreamingAssets" folder.
completeda callback method that is called when the process is completed. Returns a readable file path in case of success and returns empty in case of error.
refresh[Android][WebGL] If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
timeout[Android 2017.1+][WebGL] Sets UnityWebRequest to attempt to abort after the number of seconds in timeout has passed. No timeout is applied when timeout is set to 0 and this property defaults to 0.
Returns
returns an IEnumerator object. Yielding the IEnumerator inside a coroutine will cause the coroutine to pause until the UnityWebRequest encounters a system error or finishes communicating.

◆ getFilePathAsync() [2/3]

static IEnumerator OpenCVForUnity.UnityUtils.Utils.getFilePathAsync ( string  filepath,
Action< string >  completed,
Action< string, float >  progressChanged,
bool  refresh = false,
int  timeout = 0 
)
static

Gets the readable path of a file in the "StreamingAssets" folder by using coroutines.


Set a relative file path from the starting point of the "StreamingAssets" folder. e.g. "foobar.txt" or "hogehoge/foobar.txt".
[Android] The target file that exists in the "StreamingAssets" folder is copied into the folder of the Application.persistentDataPath. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
[WebGL] The target file in the "StreamingAssets" folder is copied to the WebGL's virtual filesystem. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.

Parameters
filepatha relative file path starting from the "StreamingAssets" folder.
completeda callback method that is called when the process is completed. Returns a readable file path in case of success and returns empty in case of error.
progressChangeda callback method that is called when the process is the progress. Returns the file path and a progress value (0.0 to 1.0).
refresh[Android][WebGL] If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
timeout[Android 2017.1+][WebGL] Sets UnityWebRequest to attempt to abort after the number of seconds in timeout has passed. No timeout is applied when timeout is set to 0 and this property defaults to 0.
Returns
returns an IEnumerator object. Yielding the IEnumerator inside a coroutine will cause the coroutine to pause until the UnityWebRequest encounters a system error or finishes communicating.

◆ getFilePathAsync() [3/3]

static IEnumerator OpenCVForUnity.UnityUtils.Utils.getFilePathAsync ( string  filepath,
Action< string >  completed,
Action< string, float >  progressChanged,
Action< string, string, long >  errorOccurred,
bool  refresh = false,
int  timeout = 0 
)
static

Gets the readable path of a file in the "StreamingAssets" folder by using coroutines.


Set a relative file path from the starting point of the "StreamingAssets" folder. e.g. "foobar.txt" or "hogehoge/foobar.txt".
[Android] The target file that exists in the "StreamingAssets" folder is copied into the folder of the Application.persistentDataPath. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
[WebGL] The target file in the "StreamingAssets" folder is copied to the WebGL's virtual filesystem. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.

Parameters
filepatha relative file path starting from the "StreamingAssets" folder.
completeda callback method that is called when the process is completed. Returns a readable file path in case of success and returns empty in case of error.
progressChangeda callback method that is called when the process is the progress. Returns the file path and a progress value (0.0 to 1.0).
errorOccurreda callback method 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 refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
timeout[Android 2017.1+][WebGL] Sets UnityWebRequest to attempt to abort after the number of seconds in timeout has passed. No timeout is applied when timeout is set to 0 and this property defaults to 0.
Returns
returns an IEnumerator object. Yielding the IEnumerator inside a coroutine will cause the coroutine to pause until the UnityWebRequest encounters a system error or finishes communicating.

◆ getMultipleFilePaths()

static List<string> OpenCVForUnity.UnityUtils.Utils.getMultipleFilePaths ( IList< string >  filepaths,
bool  refresh = false,
int  timeout = 0 
)
static

Gets the multiple readable paths of files in the "StreamingAssets" folder.


Set a relative file path from the starting point of the "StreamingAssets" folder. e.g. "foobar.txt" or "hogehoge/foobar.txt".
[Android] The target file that exists in the "StreamingAssets" folder is copied into the folder of the Application.persistentDataPath. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
[WebGL] If the target file has not yet been copied to WebGL's virtual filesystem, you need to use getFilePathAsync() at first.

Parameters
filepathsa list of relative file paths starting from the "StreamingAssets" folder.
refresh[Android] If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
timeout[Android 2017.1+] Sets UnityWebRequest to attempt to abort after the number of seconds in timeout has passed. No timeout is applied when timeout is set to 0 and this property defaults to 0.
Returns
returns a list of readable file paths. Returns a readable file path in case of success and returns empty in case of error.

◆ getMultipleFilePathsAsync() [1/4]

static IEnumerator OpenCVForUnity.UnityUtils.Utils.getMultipleFilePathsAsync ( IList< string >  filepaths,
Action< List< string >>  allCompleted,
bool  refresh = false,
int  timeout = 0 
)
static

Gets the multiple readable paths of files in the "StreamingAssets" folder by using coroutines.


Set a relative file path from the starting point of the "StreamingAssets" folder. e.g. "foobar.txt" or "hogehoge/foobar.txt".
[Android] The target file that exists in the "StreamingAssets" folder is copied into the folder of the Application.persistentDataPath. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
[WebGL] The target file in the "StreamingAssets" folder is copied to the WebGL's virtual filesystem. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.

Parameters
filepathsa list of relative file paths starting from the "StreamingAssets" folder.
allCompleteda callback method 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 empty in case of error.
refresh[Android][WebGL] If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
timeout[Android 2017.1+][WebGL] Sets UnityWebRequest to attempt to abort after the number of seconds in timeout has passed. No timeout is applied when timeout is set to 0 and this property defaults to 0.
Returns
returns an IEnumerator object. Yielding the IEnumerator inside a coroutine will cause the coroutine to pause until the UnityWebRequest encounters a system error or finishes communicating.

◆ getMultipleFilePathsAsync() [2/4]

static IEnumerator OpenCVForUnity.UnityUtils.Utils.getMultipleFilePathsAsync ( IList< string >  filepaths,
Action< List< string >>  allCompleted,
Action< string >  completed,
bool  refresh = false,
int  timeout = 0 
)
static

Gets the multiple readable paths of files in the "StreamingAssets" folder by using coroutines.


Set a relative file path from the starting point of the "StreamingAssets" folder. e.g. "foobar.txt" or "hogehoge/foobar.txt".
[Android] The target file that exists in the "StreamingAssets" folder is copied into the folder of the Application.persistentDataPath. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
[WebGL] The target file in the "StreamingAssets" folder is copied to the WebGL's virtual filesystem. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.

Parameters
filepathsa list of relative file paths starting from the "StreamingAssets" folder.
allCompleteda callback method 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 empty in case of error.
completeda callback method that is called when one process is completed. Returns a readable file path in case of success and returns empty in case of error.
refresh[Android][WebGL] If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
timeout[Android 2017.1+][WebGL] Sets UnityWebRequest to attempt to abort after the number of seconds in timeout has passed. No timeout is applied when timeout is set to 0 and this property defaults to 0.
Returns
returns an IEnumerator object. Yielding the IEnumerator inside a coroutine will cause the coroutine to pause until the UnityWebRequest encounters a system error or finishes communicating.

◆ getMultipleFilePathsAsync() [3/4]

static IEnumerator OpenCVForUnity.UnityUtils.Utils.getMultipleFilePathsAsync ( IList< string >  filepaths,
Action< List< string >>  allCompleted,
Action< string >  completed,
Action< string, float >  progressChanged,
bool  refresh = false,
int  timeout = 0 
)
static

Gets the multiple readable paths of files in the "StreamingAssets" folder by using coroutines.


Set a relative file path from the starting point of the "StreamingAssets" folder. e.g. "foobar.txt" or "hogehoge/foobar.txt".
[Android] The target file that exists in the "StreamingAssets" folder is copied into the folder of the Application.persistentDataPath. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
[WebGL] The target file in the "StreamingAssets" folder is copied to the WebGL's virtual filesystem. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.

Parameters
filepathsa list of relative file paths starting from the "StreamingAssets" folder.
allCompleteda callback method 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 empty in case of error.
completeda callback method that is called when one process is completed. Returns a readable file path in case of success and returns empty in case of error.
progressChangeda callback method that is called when one process is the progress. Returns the file path and a progress value (0.0 to 1.0).
timeout[Android 2017.1+][WebGL] Sets UnityWebRequest to attempt to abort after the number of seconds in timeout has passed. No timeout is applied when timeout is set to 0 and this property defaults to 0.
Returns
returns an IEnumerator object. Yielding the IEnumerator inside a coroutine will cause the coroutine to pause until the UnityWebRequest encounters a system error or finishes communicating.

◆ getMultipleFilePathsAsync() [4/4]

static IEnumerator OpenCVForUnity.UnityUtils.Utils.getMultipleFilePathsAsync ( IList< string >  filepaths,
Action< List< string >>  allCompleted,
Action< string >  completed,
Action< string, float >  progressChanged,
Action< string, string, long >  errorOccurred,
bool  refresh = false,
int  timeout = 0 
)
static

Gets the multiple readable paths of files in the "StreamingAssets" folder by using coroutines.


Set a relative file path from the starting point of the "StreamingAssets" folder. e.g. "foobar.txt" or "hogehoge/foobar.txt".
[Android] The target file that exists in the "StreamingAssets" folder is copied into the folder of the Application.persistentDataPath. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
[WebGL] The target file in the "StreamingAssets" folder is copied to the WebGL's virtual filesystem. If refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.

Parameters
filepathsa list of relative file paths starting from the "StreamingAssets" folder.
allCompleteda callback method 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 empty in case of error.
completeda callback method that is called when one process is completed. Returns a readable file path in case of success and returns empty in case of error.
progressChangeda callback method that is called when one process is the progress. Returns the file path and a progress value (0.0 to 1.0).
errorOccurreda callback method 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 refresh flag is false, when the file has already been copied, the file is not copied. If refresh flag is true, the file is always copied.
timeout[Android 2017.1+][WebGL] Sets UnityWebRequest to attempt to abort after the number of seconds in timeout has passed. No timeout is applied when timeout is set to 0 and this property defaults to 0.
Returns
returns an IEnumerator object. Yielding the IEnumerator inside a coroutine will cause the coroutine to pause until the UnityWebRequest encounters a system error or finishes communicating.

◆ getVersion()

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

Returns this "OpenCV for Unity" version number.

Returns
this "OpenCV for Unity" version number

◆ matToTexture2D() [1/2]

static void OpenCVForUnity.UnityUtils.Utils.matToTexture2D ( Mat  mat,
Texture2D  texture2D,
bool  flip = true,
int  flipCode = 0,
bool  flipAfter = false,
bool  updateMipmaps = false,
bool  makeNoLongerReadable = false 
)
static

Converts OpenCV Mat to Unity Texture2D.


This method converts the OpenCV Mat to the Unity Texture2D image.
The Mat object must have the types 'CV_8UC4' (RGBA) , 'CV_8UC3' (RGB) or 'CV_8UC1' (GRAY).
The texture2D object supports the following formats. (https://docs.unity3d.com/ScriptReference/Texture2D.SetPixels32.html)
The Texture2D object must have the same size as the Mat (width * height).
Enable the "unsafe" code if you want the conversion process to run the fastest; use NativeArray to run the conversion process several times faster with no overhead. If you want to use optimization code using NativeArray class, click the MenuItem[Tools/OpenCV for Unity/Open Setup Tools] - [Enable Use Unsafe Code] button.

Parameters
matthe Mat object must have the types 'CV_8UC4' (RGBA) , 'CV_8UC3' (RGB) or 'CV_8UC1' (GRAY)
texture2Dthe texture2D object supports the following formats. (https://docs.unity3d.com/ScriptReference/Texture2D.SetPixels32.html) The Texture2D object must have the same size as the Mat (width * height).
flipif true, the mat is fliped before converting.
flipCodea flag to specify how to flip the array; 0 means flipping around the x-axis and positive value (for example, 1) means flipping around y-axis. Negative value (for example, -1) means flipping around both axes.
flipAfterif true, the mat is fliped after converting. If you want to use mat even after calling this method, set true.
updateMipmapsWhen set to true, mipmap levels are recalculated.
makeNoLongerReadableWhen set to true, system memory copy of a texture is released.

◆ matToTexture2D() [2/2]

static void OpenCVForUnity.UnityUtils.Utils.matToTexture2D ( Mat  mat,
Texture2D  texture2D,
Color32 []  pixels32Buffer,
byte []  rawTextureDataBuffer = null,
bool  flip = true,
int  flipCode = 0,
bool  flipAfter = false,
bool  updateMipmaps = false,
bool  makeNoLongerReadable = false 
)
static

Converts OpenCV Mat to Unity Texture2D.


This method converts the OpenCV Mat to the Unity Texture2D image.
The Mat object must have the types 'CV_8UC4' (RGBA) , 'CV_8UC3' (RGB) or 'CV_8UC1' (GRAY).
The texture2D object supports the following formats. (https://docs.unity3d.com/ScriptReference/Texture2D.SetPixels32.html)
The Texture2D object must have the same size as the Mat (width * height).
Enable the "unsafe" code if you want the conversion process to run the fastest; use NativeArray to run the conversion process several times faster with no overhead. If you want to use optimization code using NativeArray class, click the MenuItem[Tools/OpenCV for Unity/Open Setup Tools] - [Enable Use Unsafe Code] button.

Parameters
matthe Mat object must have the types 'CV_8UC4' (RGBA) , 'CV_8UC3' (RGB) or 'CV_8UC1' (GRAY)
texture2DThe texture2D object supports the following formats. (https://docs.unity3d.com/ScriptReference/Texture2D.SetPixels32.html) The Texture2D object must have the same size as the Mat (width * height).
pixels32Bufferthe optional array to receive pixels32 data. You can optionally pass in an array of Color32s to avoid allocating new memory each frame. The array needs to be initialized to a length matching width * height of the texture. (http://docs.unity3d.com/ScriptReference/WebCamTexture.GetPixels32.html)
rawTextureDataBufferthe optional array to receive raw texture data. You can optionally pass in an array of bytes to avoid allocating new memory each frame. The array needs to be initialized to a length matching raw data of the texture. (https://docs.unity3d.com/ScriptReference/Texture2D.GetRawTextureData.html)
flipif true, the mat is fliped before converting.
flipCodea flag to specify how to flip the array; 0 means flipping around the x-axis and positive value (for example, 1) means flipping around y-axis. Negative value (for example, -1) means flipping around both axes.
flipAfterif true, the mat is fliped after converting. If you want to use mat even after calling this method, set true.
updateMipmapswhen set to true, mipmap levels are recalculated.
makeNoLongerReadablewhen set to true, system memory copy of a texture is released.

◆ setDebugMode()

static void OpenCVForUnity.UnityUtils.Utils.setDebugMode ( bool  debugMode,
bool  throwException = false,
Action< string >  callback = null 
)
static

Sets the debug mode.


if debugMode is true, The error log of the Native side OpenCV will be displayed on the Unity Editor Console.However, if throwException is true, CvException is thrown instead of calling Debug.LogError (msg).
Please use as follows.
Utils.setDebugMode(true);
aaa
bbb
ccc
Utils.setDebugMode(false);

Parameters
debugModeif true, The error log of the Native side OpenCV will be displayed on the Unity Editor Console.
throwExceptionif true, CvException is thrown instead of calling Debug.LogError (msg).
callbackcallback called when an OpenCV error occurs on the Native side.

◆ texture2DToMat()

static void OpenCVForUnity.UnityUtils.Utils.texture2DToMat ( Texture2D  texture2D,
Mat  mat,
bool  flipAfter = true,
int  flipCode = 0 
)
static

Converts Unity Texture2D to OpenCV Mat.


This method converts the Unity Texture2D image to the OpenCV Mat.
The Texture object must have the read/write enabled flag set in the texture import settings, otherwise this function will fail. (GetPixels32() method is needed.)
The Mat object must have the same size as the Texture2D (width * height).
The Mat object must have the types 'CV_8UC4' (RGBA) , 'CV_8UC3' (RGB) or 'CV_8UC1' (GRAY).
Enable the "unsafe" code if you want the conversion process to run the fastest; use NativeArray to run the conversion process several times faster with no overhead. If you want to use optimization code using NativeArray class, click the MenuItem[Tools/OpenCV for Unity/Open Setup Tools] - [Enable Use Unsafe Code] button.

Parameters
texture2Dthe Texture2D object must have the read/write enabled flag set in the texture import settings, otherwise this function will fail. (GetPixels32() method is needed.)
matthe Mat object must have the same size as the Texture2D (width * height). The Mat object must have the types 'CV_8UC4' (RGBA) , 'CV_8UC3' (RGB) or 'CV_8UC1' (GRAY).
flipAfterif true, the mat is fliped after converting.
flipCodea flag to specify how to flip the array; 0 means flipping around the x-axis and positive value (for example, 1) means flipping around y-axis. Negative value (for example, -1) means flipping around both axes.

◆ textureToTexture2D()

static void OpenCVForUnity.UnityUtils.Utils.textureToTexture2D ( Texture  texture,
Texture2D  texture2D 
)
static

Converts Texture to Texture2D.


This method converts the Texture image to the Texture2D image.
The texture and texture2D need to be the same size.
The texture2D's TextureFormat needs to be RGBA32, ARGB32, RGB24, RGBAFloat or RGBAHalf.

Parameters
texturea texture object.
texture2Da texture2D object.

◆ webCamTextureToMat() [1/2]

static void OpenCVForUnity.UnityUtils.Utils.webCamTextureToMat ( WebCamTexture  webCamTexture,
Mat  mat,
bool  flipAfter = true,
int  flipCode = 0 
)
static

Converts Unity WebCamTexture to OpenCV Mat.


This method converts the Unity WebCamTexture image to the OpenCV Mat.
The Mat object must have the same size as the WebCamTexture (width * height).
The Mat object must have the types 'CV_8UC4' (RGBA) , 'CV_8UC3' (RGB) or 'CV_8UC1' (GRAY).

Parameters
webcamTexturea WebCamTexture object.
matthe Mat object must have the same size as the WebCamTexture (width * height). The Mat object must have the types 'CV_8UC4' (RGBA) , 'CV_8UC3' (RGB) or 'CV_8UC1' (GRAY).
flipAfterif true, the mat is fliped after converting.
flipCodea flag to specify how to flip the array; 0 means flipping around the x-axis and positive value (for example, 1) means flipping around y-axis. Negative value (for example, -1) means flipping around both axes.

◆ webCamTextureToMat() [2/2]

static void OpenCVForUnity.UnityUtils.Utils.webCamTextureToMat ( WebCamTexture  webCamTexture,
Mat  mat,
Color32 []  pixels32Buffer,
bool  flipAfter = true,
int  flipCode = 0 
)
static

Converts Unity WebCamTexture to OpenCV Mat.


This method converts the Unity WebCamTexture image to the OpenCV Mat.
The Mat object must have the same size as the WebCamTexture (width * height).
The Mat object must have the types 'CV_8UC4' (RGBA) , 'CV_8UC3' (RGB) or 'CV_8UC1' (GRAY).

Parameters
webcamTexturea WebCamTexture object.
matthe Mat object must have the same size as the WebCamTexture' (width * height). The Mat object must have the types 'CV_8UC4' (RGBA) , 'CV_8UC3' (RGB) or 'CV_8UC1' (GRAY).
bufferColorsthe optional array to receive pixel data. You can optionally pass in an array of Color32s to use in colors to avoid allocating new memory each frame. The array needs to be initialized to a length matching width * height of the texture. (http://docs.unity3d.com/ScriptReference/WebCamTexture.GetPixels32.html)
flipAfterif true, the mat is fliped after converting.
flipCodea flag to specify how to flip the array; 0 means flipping around the x-axis and positive value (for example, 1) means flipping around y-axis. Negative value (for example, -1) means flipping around both axes.

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