OpenCV for Unity 2.6.4
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 versatile helper component class for obtaining frames as OpenCV Mat
objects from multiple sources, allowing dynamic switching between different ISource2MatHelper
classes.
More...
Public Types | |
enum | MultiSource2MatHelperClassCategory : int { Camera = 0 , Video , Image , Texture , Custom } |
enum | MultiSource2MatHelperClassName : int { WebCamTexture2MatHelper = 0 , VideoCapture2MatHelper , UnityVideoPlayer2MatHelper , Image2MatHelper , AsyncGPUReadback2MatHelper , WebCamTexture2MatAsyncGPUHelper , CustomSource2MatHelper } |
Public Member Functions | |
virtual bool | DidUpdateThisFrame () |
Indicate whether the source buffer of the frame has been updated. | |
virtual void | Dispose () |
virtual Source2MatHelperColorFormat | GetBaseColorFormat () |
Return the source base color format. | |
virtual MultiSource2MatHelperClassName | GetCurrentSource2MatHelperClassName () |
virtual string | GetDeviceName () |
Return the source device name. | |
virtual int | GetHeight () |
Return the source height. | |
virtual Mat | GetMat () |
Get the mat of the current frame. | |
virtual int | GetWidth () |
Return the source width. | |
virtual void | Initialize (bool autoPlay=true) |
Initialize this instance. | |
virtual bool | IsInitialized () |
Indicate whether this instance has been initialized. | |
virtual bool | IsPaused () |
Indicate whether the device is paused. | |
virtual bool | IsPlaying () |
Indicate whether the source device is currently playing. | |
virtual void | Pause () |
Pause the source device. | |
virtual void | Play () |
Start the source device. | |
virtual void | Stop () |
Stop the source device. | |
Public Member Functions inherited from OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper |
Protected Member Functions | |
virtual MultiSource2MatHelperClassCategory | ClassNameToClassCategory (MultiSource2MatHelperClassName className) |
virtual void | OnValidate () |
Protected Attributes | |
MultiSource2MatHelperClassCategory | _currentSource2MatHelperClassCategory = MultiSource2MatHelperClassCategory.Camera |
MultiSource2MatHelperClassName | _currentSource2MatHelperClassName = MultiSource2MatHelperClassName.WebCamTexture2MatHelper |
Component | _customClassComponent = null |
Set the custom class <ISource2MatHelper> component. | |
bool | _loop = true |
Indicate whether to play this video in a loop. | |
UnityEvent | _onDisposed |
UnityEvent that is triggered when this instance is disposed. | |
Source2MatHelperErrorUnityEvent | _onErrorOccurred |
UnityEvent that is triggered when this instance is error Occurred. | |
UnityEvent | _onInitialized |
UnityEvent that is triggered when this instance is initialized. | |
Source2MatHelperColorFormat | _outputColorFormat = Source2MatHelperColorFormat.RGBA |
Select the output color format. | |
bool | _repeat = true |
Indicate whether to play this image in a repeat. | |
string | _requestedDeviceName = null |
Set the name of the camera device to use. (or device index number) | |
float | _requestedFPS = 30f |
Set the frame rate of camera. | |
int | _requestedHeight = 480 |
Set the height of camera. | |
string | _requestedImageFilePath = string.Empty |
Set the image file path, relative to the starting point of the "StreamingAssets" folder, or absolute path. | |
bool | _requestedIsFrontFacing = false |
Set whether to use the front facing camera. | |
MultiSource2MatHelperClassName | _requestedSource2MatHelperClassName = MultiSource2MatHelperClassName.WebCamTexture2MatHelper |
Select the source to mat helper class name. If CustomSource2MatHelper is selected, only the UnityEvent inspector is overridden for the custom helper class component. | |
string | _requestedVideoFilePath = string.Empty |
Set the video file path, relative to the starting point of the "StreamingAssets" folder, or absolute path. | |
int | _requestedWidth = 640 |
Set the width of camera. | |
ISource2MatHelper | _source2MatHelper |
Texture | _sourceTexture |
Set the source texture. | |
int | _timeoutFrameCount = 1500 |
The number of frames before the initialization process times out. | |
bool | autoPlayAfterInitialize |
If set to true play after completion of initialization. | |
Properties | |
virtual Component | customClassComponent [get, set] |
virtual bool | loop [get, set] |
UnityEvent | onDisposed [get, set] |
Source2MatHelperErrorUnityEvent | onErrorOccurred [get, set] |
UnityEvent | onInitialized [get, set] |
virtual Source2MatHelperColorFormat | outputColorFormat [get, set] |
virtual bool | repeat [get, set] |
virtual string | requestedDeviceName [get, set] |
virtual float | requestedFPS [get, set] |
virtual int | requestedHeight [get, set] |
virtual string | requestedImageFilePath [get, set] |
virtual bool | requestedIsFrontFacing [get, set] |
MultiSource2MatHelperClassName | requestedSource2MatHelperClassName [get, set] |
virtual string | requestedVideoFilePath [get, set] |
virtual int | requestedWidth [get, set] |
ISource2MatHelper | source2MatHelper [get] |
virtual Texture | sourceTexture [get, set] |
virtual int | timeoutFrameCount [get, set] |
Properties inherited from OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper |
A versatile helper component class for obtaining frames as OpenCV Mat
objects from multiple sources, allowing dynamic switching between different ISource2MatHelper
classes.
The MultiSource2MatHelper
class integrates various ISource2MatHelper
implementations, such as WebCamTexture2MatHelper
, VideoCapture2MatHelper
, UnityVideoPlayer2MatHelper
, and Image2MatHelper
, providing a unified interface for accessing frames as Mat
objects. Through settings in the Inspector or during runtime, users can select or switch between these helper classes to obtain frames from different sources, such as webcams, video files, images, or textures.
This component is particularly useful for applications requiring flexible frame input sources, making it easy to integrate various media types into OpenCV-based processing workflows within Unity.
Attach this component to a GameObject and select the desired source in the Inspector. Use GetMat()
to retrieve the current frame as a Mat
object. The helper class manages source initialization, switching, and frame updates as needed.
|
protectedvirtual |
|
virtual |
Indicate whether the source buffer of the frame has been updated.
true
, if the source buffer has been updated false
otherwise.Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
|
virtual |
Return the source base color format.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
|
virtual |
Return the source device name.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Return the source 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 source 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 |
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 device is paused.
true
, if the device is paused, false
otherwise.Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Indicate whether the source device is currently playing.
true
, if the source device is playing, false
otherwise.Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
protectedvirtual |
|
virtual |
Pause the source device.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Start the source device.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
virtual |
Stop the source device.
Implements OpenCVForUnity.UnityUtils.Helper.ISource2MatHelper.
|
protected |
|
protected |
|
protected |
Set the custom class <ISource2MatHelper> component.
|
protected |
Indicate whether to play this video in a loop.
|
protected |
UnityEvent that is triggered when this instance is disposed.
|
protected |
UnityEvent that is triggered when this instance is error Occurred.
|
protected |
UnityEvent that is triggered when this instance is initialized.
|
protected |
Select the output color format.
|
protected |
Indicate whether to play this image in a repeat.
|
protected |
Set the name of the camera device to use. (or device index number)
|
protected |
Set the frame rate of camera.
|
protected |
Set the height of camera.
|
protected |
Set the image file path, relative to the starting point of the "StreamingAssets" folder, or absolute path.
|
protected |
Set whether to use the front facing camera.
|
protected |
Select the source to mat helper class name. If CustomSource2MatHelper is selected, only the UnityEvent inspector is overridden for the custom helper class component.
|
protected |
Set the video file path, relative to the starting point of the "StreamingAssets" folder, or absolute path.
|
protected |
Set the width of camera.
|
protected |
|
protected |
Set the source texture.
|
protected |
The number of frames before the initialization process times out.
|
protected |
If set to true play after completion of initialization.
|
getset |
|
getset |
|
getset |
|
getset |
|
getset |
|
getset |
|
getset |
|
getset |
|
getset |
|
getset |
|
getset |
|
getset |
|
getset |
|
getset |
|
getset |
|
get |
|
getset |
|
getset |