OpenCV for Unity 2.6.5
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/4.10.0/index.html ) for the details of the argument of the method.
|
A helper component class for loading an image file using OpenCV's Imgcodecs.imread
method and converting it to an OpenCV Mat
format.
More...
Public Member Functions | |
virtual bool | DidUpdateThisFrame () |
Use this to check if the Mat has changed since the last frame. Since it would not make sense to do expensive video processing in each Update call, check this value before doing any processing. | |
virtual void | Dispose () |
Releases all resource used by the Image2MatHelper object. | |
virtual Source2MatHelperColorFormat | GetBaseColorFormat () |
Return the image base color format. | |
virtual string | GetDeviceName () |
Return the active image device name. | |
virtual int | GetHeight () |
Return the image height. | |
virtual Mat | GetMat () |
Get the mat of the current frame. | |
virtual float | GetMatUpdateFPS () |
Return the frame rate at which the Mat is updated. (interval at which the DidUpdateThisFrame() method becomes true). | |
virtual int | GetWidth () |
Return the image width. | |
virtual void | Initialize (bool autoPlay=true) |
Initialize this instance. | |
virtual void | Initialize (string requestedImageFilePath, bool autoPlay=true) |
Initialize this instance. | |
virtual bool | IsInitialized () |
Indicate whether this instance has been initialized. | |
virtual bool | IsPaused () |
Indicate whether the image is paused. | |
virtual bool | IsPlaying () |
Indicate whether the image is currently playing. | |
virtual void | Pause () |
Pause the image. | |
virtual void | Play () |
Start the image. | |
virtual void | Stop () |
Stop the image. | |
Public Member Functions inherited from OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper | |
Public Member Functions inherited from OpenCVForUnity.UnityUtils.Helper.IMatUpdateFPSProvider |
Protected Member Functions | |
virtual IEnumerator | _Initialize () |
Initialize this instance by coroutine. | |
virtual IEnumerator | _WaitForEndOfFrameCoroutine () |
virtual void | CallReadFrame () |
virtual void | CancelInitCoroutine () |
Cancel Init Coroutine. | |
virtual void | CancelWaitForEndOfFrameCoroutine () |
Cancel WaitForEndOfFrame Coroutine. | |
virtual void | OnDestroy () |
Raises the destroy event. | |
virtual void | OnValidate () |
virtual void | ReadFrame () |
virtual void | ReleaseResources () |
To release the resources. | |
virtual void | Update () |
Protected Attributes | |
Mat | _imageBufferMat |
System.Object | _imageBufferMatLockObject = new System.Object() |
UnityEvent | _onDisposed |
Source2MatHelperErrorUnityEvent | _onErrorOccurred |
UnityEvent | _onInitialized |
Source2MatHelperColorFormat | _outputColorFormat = Source2MatHelperColorFormat.BGR |
bool | _repeat = true |
string | _requestedImageFilePath = string.Empty |
float | _requestedMatUpdateFPS = 30f |
int | _timeoutFrameCount = 1500 |
bool | autoPlayAfterInitialize |
If set to true play after completion of initialization. | |
Source2MatHelperColorFormat | baseColorFormat = Source2MatHelperColorFormat.BGR |
The base color format. | |
Mat | baseMat |
The base mat. | |
bool | didUpdateThisFrame = false |
Whether the mat that can be obtained with the GetMat method has been updated in this frame. This flag is changed after waiting until WaitForEndOfFrame in the coroutine. | |
Mat | frameMat |
The frame mat. | |
IEnumerator | getFilePathCoroutine |
The get file path coroutine. | |
bool | hasInitDone = false |
Indicates whether this instance has been initialized. | |
string | imageFileFullPath |
imageFileFullPath | |
IEnumerator | initCoroutine |
The initialization coroutine. | |
bool | isInitWaiting = false |
Indicates whether this instance is waiting for initialization to complete. | |
bool | isPlaying = false |
isPlaying | |
IEnumerator | waitForEndOfFrameCoroutine |
The waitForEndOfFrameCoroutine. | |
Properties | |
Mat | imageBufferMat [get, set] |
The image buffer mat. | |
UnityEvent | onDisposed [get, set] |
UnityEvent that is triggered when this instance is disposed. | |
Source2MatHelperErrorUnityEvent | onErrorOccurred [get, set] |
UnityEvent that is triggered when this instance is error Occurred. | |
UnityEvent | onInitialized [get, set] |
UnityEvent that is triggered when this instance is initialized. | |
virtual Source2MatHelperColorFormat | outputColorFormat [get, set] |
Select the output color format. | |
virtual bool | repeat [get, set] |
Indicate whether to play this image in a repeat. | |
virtual string | requestedImageFilePath [get, set] |
Set the image file path, relative to the starting point of the "StreamingAssets" folder, or absolute path. | |
virtual float | requestedMatUpdateFPS [get, set] |
Sets the frame rate at which the Mat is updated. (interval at which the DidUpdateThisFrame() method becomes true). | |
virtual int | timeoutFrameCount [get, set] |
The number of frames before the initialization process times out. | |
Properties inherited from OpenCVForUnity.UnityUtils.Helper.IImageSource2MatHelper | |
Properties inherited from OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper | |
Properties inherited from OpenCVForUnity.UnityUtils.Helper.IMatUpdateFPSProvider |
A helper component class for loading an image file using OpenCV's Imgcodecs.imread
method and converting it to an OpenCV Mat
format.
The Image2MatHelper
class reads an image file from the specified path and converts it to an OpenCV Mat
object using Imgcodecs.imread
. This component simplifies the process of loading images for applications that require image processing in Unity with OpenCV.
This component is particularly useful for static image processing tasks, enabling seamless integration of OpenCV-based algorithms with image files directly within Unity.
Note: By setting outputColorFormat to GRAY or BGR, processing that does not include extra color conversion is performed.
Attach this component to a GameObject and call GetMat()
to retrieve the latest image frame in Mat
format.
|
protectedvirtual |
Initialize this instance by coroutine.
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
Cancel Init Coroutine.
|
protectedvirtual |
Cancel WaitForEndOfFrame Coroutine.
|
virtual |
Use this to check if the Mat has changed since the last frame. Since it would not make sense to do expensive video processing in each Update call, check this value before doing any processing.
true
, if the Mat has been updated false
otherwise.Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Releases all resource used by the Image2MatHelper object.
Call Dispose when you are finished using the Image2MatHelper. The Dispose method leaves the Image2MatHelper in an unusable state. After calling Dispose, you must release all references to the Image2MatHelper so the garbage collector can reclaim the memory that the Image2MatHelper was occupying.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Return the image base color format.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Return the active image device name.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Return the image height.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Get the mat of the current frame.
The Mat object's type is 'CV_8UC4' or 'CV_8UC3' or 'CV_8UC1' (ColorFormat is determined by the outputColorFormat setting). Please do not dispose of the returned mat as it will be reused.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Return the frame rate at which the Mat is updated. (interval at which the DidUpdateThisFrame() method becomes true).
Implements OpenCVForUnity.UnityUtils.Helper.IMatUpdateFPSProvider.
|
virtual |
Return the image width.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Initialize this instance.
autoPlay | If set to true play after completion of initialization. |
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Initialize this instance.
requestedImageFilePath | Requested image file path. |
autoPlay | If set to true play after completion of initialization. |
|
virtual |
Indicate whether this instance has been initialized.
true
, if this instance has been initialized, false
otherwise.Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Indicate whether the image is paused.
true
, if the image is paused, false
otherwise.Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Indicate whether the image is currently playing.
true
, if the image is playing, false
otherwise.Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
protectedvirtual |
Raises the destroy event.
|
protectedvirtual |
|
virtual |
Pause the image.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Start the image.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
protectedvirtual |
|
protectedvirtual |
To release the resources.
|
virtual |
Stop the image.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
protectedvirtual |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
If set to true play after completion of initialization.
|
protected |
The base color format.
|
protected |
The base mat.
|
protected |
Whether the mat that can be obtained with the GetMat method has been updated in this frame. This flag is changed after waiting until WaitForEndOfFrame in the coroutine.
|
protected |
The frame mat.
|
protected |
The get file path coroutine.
|
protected |
Indicates whether this instance has been initialized.
|
protected |
imageFileFullPath
|
protected |
The initialization coroutine.
|
protected |
Indicates whether this instance is waiting for initialization to complete.
|
protected |
isPlaying
|
protected |
The waitForEndOfFrameCoroutine.
|
getsetprotected |
The image buffer mat.
|
getset |
UnityEvent that is triggered when this instance is disposed.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
getset |
UnityEvent that is triggered when this instance is error Occurred.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
getset |
UnityEvent that is triggered when this instance is initialized.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
getset |
Select the output color format.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
getset |
Indicate whether to play this image in a repeat.
Implements OpenCVForUnity.UnityUtils.Helper.IImageSource2MatHelper.
|
getset |
Set the image file path, relative to the starting point of the "StreamingAssets" folder, or absolute path.
Implements OpenCVForUnity.UnityUtils.Helper.IImageSource2MatHelper.
|
getset |
Sets the frame rate at which the Mat is updated. (interval at which the DidUpdateThisFrame() method becomes true).
Implements OpenCVForUnity.UnityUtils.Helper.IMatUpdateFPSProvider.
|
getset |
The number of frames before the initialization process times out.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.