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.
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | List of all members
OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper Class Reference

VideoCapture to mat helper. v 1.0.4 More...

Inheritance diagram for OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper:

Classes

class  ErrorUnityEvent
 

Public Types

enum  ColorFormat : int {
  ColorFormat.GRAY = 0, ColorFormat.RGB, ColorFormat.BGR, ColorFormat.RGBA,
  ColorFormat.BGRA
}
 
enum  ErrorCode : int { ErrorCode.UNKNOWN = 0, ErrorCode.VIDEO_FILE_NOT_EXIST, ErrorCode.VIDEO_FILE_CANT_OPEN, ErrorCode.TIMEOUT }
 

Public Member Functions

virtual void Initialize ()
 Initializes this instance. More...
 
virtual void Initialize (string requestedVideoFilePath)
 Initializes this instance. More...
 
virtual bool IsInitialized ()
 Indicates whether this instance has been initialized. More...
 
virtual void Play ()
 Starts the video. More...
 
virtual void Pause ()
 Pauses the video. More...
 
virtual void Stop ()
 Stops the video. More...
 
virtual bool IsPlaying ()
 Indicates whether the video is currently playing. More...
 
virtual int GetWidth ()
 Returns the video width. More...
 
virtual int GetHeight ()
 Returns the video height. More...
 
virtual float GetFPS ()
 Returns the video framerate. More...
 
virtual float GetPosRatio ()
 Returns the relative position of the video file: 0=start of the film, 1=end of the film. More...
 
virtual void SetPosRatio (float ratio)
 Sets the relative position of the video file: 0=start of the film, 1=end of the film. More...
 
virtual ColorFormat GetBaseColorFormat ()
 Returns the video base color format. More...
 
virtual VideoCapture GetVideoCapture ()
 Returns the VideoCapture instance. More...
 
virtual bool DidUpdateThisFrame ()
 Indicates whether the video buffer of the frame has been updated. More...
 
virtual Mat GetMat ()
 Gets 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). More...
 
virtual void Dispose ()
 Releases all resource used by the VideoCaptrueToMatHelper object. More...
 

Public Attributes

UnityEvent onInitialized
 UnityEvent that is triggered when this instance is initialized. More...
 
UnityEvent onDisposed
 UnityEvent that is triggered when this instance is disposed. More...
 
ErrorUnityEvent onErrorOccurred
 UnityEvent that is triggered when this instance is error Occurred. More...
 

Protected Member Functions

virtual void OnValidate ()
 
virtual void LateUpdate ()
 
virtual void ReadFrame ()
 
virtual void OnDestroy ()
 Raises the destroy event. More...
 
virtual IEnumerator _Initialize ()
 Initializes this instance by coroutine. More...
 
virtual void StartWaitFrameTimeThread ()
 
virtual void StopWaitFrameTimeThread ()
 
virtual void WaitFrameTimeThreadWorker ()
 
virtual int Channels (ColorFormat type)
 
virtual int ColorConversionCodes (ColorFormat srcType, ColorFormat dstType)
 
virtual void CancelInitCoroutine ()
 Cancel Init Coroutine. More...
 
virtual void ReleaseResources ()
 To release the resources. More...
 

Protected Attributes

string _requestedVideoFilePath = string.Empty
 Set the video file path. More...
 
int _apiPreference = Videoio.CAP_ANY
 Set the apiPreference. VideoCapture API backends identifier. (Advanced Option) See ReadMe.pdf for setup instructions for using CAP_FFMPEG on Windows platforms. More...
 
ColorFormat _outputColorFormat = ColorFormat.BGR
 Select the output color format. More...
 
int _timeoutFrameCount = 1500
 The number of frames before the initialization process times out. More...
 
bool _loop = true
 Indicates whether to play this video in a loop. More...
 
System.Object videoCaptureLockObject = new System.Object()
 The VideoCapture. More...
 
VideoCapture _videoCapture
 
System.Object sync = new System.Object()
 
bool _isReading = false
 
bool _isPlaying = false
 
bool _didUpdateThisFrame = false
 
bool _didUpdateImageBufferInCurrentFrame = false
 
Mat frameMat
 The frame mat. More...
 
Mat baseMat
 The base mat. More...
 
System.Object imageBufferMatLockObject = new System.Object()
 The image buffer mat. More...
 
Mat _imageBufferMat
 
ColorFormat baseColorFormat = ColorFormat.BGR
 The base color format. More...
 
bool isInitWaiting = false
 Indicates whether this instance is waiting for initialization to complete. More...
 
bool hasInitDone = false
 Indicates whether this instance has been initialized. More...
 
IEnumerator initCoroutine
 The initialization coroutine. More...
 
IEnumerator getFilePathCoroutine
 The get file path coroutine. More...
 
bool _isThreadRunning = false
 
bool _shouldStopThread = false
 

Properties

virtual string requestedVideoFilePath [get, set]
 
virtual int apiPreference [get, set]
 
virtual ColorFormat outputColorFormat [get, set]
 
virtual int timeoutFrameCount [get, set]
 
virtual bool loop [get, set]
 
VideoCapture videoCapture [get, set]
 
virtual bool isReading [get, set]
 
virtual bool isPlaying [get, set]
 
virtual bool didUpdateThisFrame [get, set]
 
virtual bool didUpdateImageBufferInCurrentFrame [get, set]
 
Mat imageBufferMat [get, set]
 
virtual bool isThreadRunning [get, set]
 
virtual bool shouldStopThread [get, set]
 

Detailed Description

VideoCapture to mat helper. v 1.0.4

Member Enumeration Documentation

◆ ColorFormat

Enumerator
GRAY 
RGB 
BGR 
RGBA 
BGRA 

◆ ErrorCode

Enumerator
UNKNOWN 
VIDEO_FILE_NOT_EXIST 
VIDEO_FILE_CANT_OPEN 
TIMEOUT 

Member Function Documentation

◆ _Initialize()

virtual IEnumerator OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper._Initialize ( )
protectedvirtual

Initializes this instance by coroutine.

◆ CancelInitCoroutine()

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.CancelInitCoroutine ( )
protectedvirtual

Cancel Init Coroutine.

◆ Channels()

virtual int OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.Channels ( ColorFormat  type)
protectedvirtual

◆ ColorConversionCodes()

virtual int OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.ColorConversionCodes ( ColorFormat  srcType,
ColorFormat  dstType 
)
protectedvirtual

◆ DidUpdateThisFrame()

virtual bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.DidUpdateThisFrame ( )
virtual

Indicates whether the video buffer of the frame has been updated.

Returns
true, if the video buffer has been updated false otherwise.

◆ Dispose()

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.Dispose ( )
virtual

Releases all resource used by the VideoCaptrueToMatHelper object.

Call Dispose when you are finished using the VideoCaptrueToMatHelper. The Dispose method leaves the VideoCaptrueToMatHelper in an unusable state. After calling Dispose, you must release all references to the VideoCaptrueToMatHelper so the garbage collector can reclaim the memory that the VideoCaptrueToMatHelper was occupying.

◆ GetBaseColorFormat()

virtual ColorFormat OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.GetBaseColorFormat ( )
virtual

Returns the video base color format.

Returns
The video base color format.

◆ GetFPS()

virtual float OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.GetFPS ( )
virtual

Returns the video framerate.

Returns
The video framerate.

◆ GetHeight()

virtual int OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.GetHeight ( )
virtual

Returns the video height.

Returns
The video height.

◆ GetMat()

virtual Mat OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.GetMat ( )
virtual

Gets 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).

Returns
The mat of the current frame.

◆ GetPosRatio()

virtual float OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.GetPosRatio ( )
virtual

Returns the relative position of the video file: 0=start of the film, 1=end of the film.

Returns
The relative position of the video file: 0=start of the film, 1=end of the film.

◆ GetVideoCapture()

virtual VideoCapture OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.GetVideoCapture ( )
virtual

Returns the VideoCapture instance.

Returns
The VideoCapture instance.

◆ GetWidth()

virtual int OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.GetWidth ( )
virtual

Returns the video width.

Returns
The video width.

◆ Initialize() [1/2]

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.Initialize ( )
virtual

Initializes this instance.

◆ Initialize() [2/2]

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.Initialize ( string  requestedVideoFilePath)
virtual

Initializes this instance.

Parameters
requestedVideoFilePathRequested video file path.

◆ IsInitialized()

virtual bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.IsInitialized ( )
virtual

Indicates whether this instance has been initialized.

Returns
true, if this instance has been initialized, false otherwise.

◆ IsPlaying()

virtual bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.IsPlaying ( )
virtual

Indicates whether the video is currently playing.

Returns
true, if the video is playing, false otherwise.

◆ LateUpdate()

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.LateUpdate ( )
protectedvirtual

◆ OnDestroy()

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.OnDestroy ( )
protectedvirtual

Raises the destroy event.

◆ OnValidate()

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.OnValidate ( )
protectedvirtual

◆ Pause()

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.Pause ( )
virtual

Pauses the video.

◆ Play()

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.Play ( )
virtual

Starts the video.

◆ ReadFrame()

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.ReadFrame ( )
protectedvirtual

◆ ReleaseResources()

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.ReleaseResources ( )
protectedvirtual

To release the resources.

◆ SetPosRatio()

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.SetPosRatio ( float  ratio)
virtual

Sets the relative position of the video file: 0=start of the film, 1=end of the film.

Parameters
ratioThe relative position of the video file: 0=start of the film, 1=end of the film.

◆ StartWaitFrameTimeThread()

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.StartWaitFrameTimeThread ( )
protectedvirtual

◆ Stop()

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.Stop ( )
virtual

Stops the video.

◆ StopWaitFrameTimeThread()

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.StopWaitFrameTimeThread ( )
protectedvirtual

◆ WaitFrameTimeThreadWorker()

virtual void OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.WaitFrameTimeThreadWorker ( )
protectedvirtual

Member Data Documentation

◆ _apiPreference

int OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper._apiPreference = Videoio.CAP_ANY
protected

Set the apiPreference. VideoCapture API backends identifier. (Advanced Option) See ReadMe.pdf for setup instructions for using CAP_FFMPEG on Windows platforms.

◆ _didUpdateImageBufferInCurrentFrame

bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper._didUpdateImageBufferInCurrentFrame = false
protected

◆ _didUpdateThisFrame

bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper._didUpdateThisFrame = false
protected

◆ _imageBufferMat

Mat OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper._imageBufferMat
protected

◆ _isPlaying

bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper._isPlaying = false
protected

◆ _isReading

bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper._isReading = false
protected

◆ _isThreadRunning

bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper._isThreadRunning = false
protected

◆ _loop

bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper._loop = true
protected

Indicates whether to play this video in a loop.

◆ _outputColorFormat

ColorFormat OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper._outputColorFormat = ColorFormat.BGR
protected

Select the output color format.

◆ _requestedVideoFilePath

string OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper._requestedVideoFilePath = string.Empty
protected

Set the video file path.

◆ _shouldStopThread

bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper._shouldStopThread = false
protected

◆ _timeoutFrameCount

int OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper._timeoutFrameCount = 1500
protected

The number of frames before the initialization process times out.

◆ _videoCapture

VideoCapture OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper._videoCapture
protected

◆ baseColorFormat

ColorFormat OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.baseColorFormat = ColorFormat.BGR
protected

The base color format.

◆ baseMat

Mat OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.baseMat
protected

The base mat.

◆ frameMat

Mat OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.frameMat
protected

The frame mat.

◆ getFilePathCoroutine

IEnumerator OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.getFilePathCoroutine
protected

The get file path coroutine.

◆ hasInitDone

bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.hasInitDone = false
protected

Indicates whether this instance has been initialized.

◆ imageBufferMatLockObject

System.Object OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.imageBufferMatLockObject = new System.Object()
protected

The image buffer mat.

◆ initCoroutine

IEnumerator OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.initCoroutine
protected

The initialization coroutine.

◆ isInitWaiting

bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.isInitWaiting = false
protected

Indicates whether this instance is waiting for initialization to complete.

◆ onDisposed

UnityEvent OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.onDisposed

UnityEvent that is triggered when this instance is disposed.

◆ onErrorOccurred

ErrorUnityEvent OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.onErrorOccurred

UnityEvent that is triggered when this instance is error Occurred.

◆ onInitialized

UnityEvent OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.onInitialized

UnityEvent that is triggered when this instance is initialized.

◆ sync

System.Object OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.sync = new System.Object()
protected

◆ videoCaptureLockObject

System.Object OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.videoCaptureLockObject = new System.Object()
protected

The VideoCapture.

Property Documentation

◆ apiPreference

virtual int OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.apiPreference
getset

◆ didUpdateImageBufferInCurrentFrame

virtual bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.didUpdateImageBufferInCurrentFrame
getsetprotected

◆ didUpdateThisFrame

virtual bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.didUpdateThisFrame
getsetprotected

◆ imageBufferMat

Mat OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.imageBufferMat
getsetprotected

◆ isPlaying

virtual bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.isPlaying
getsetprotected

◆ isReading

virtual bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.isReading
getsetprotected

◆ isThreadRunning

virtual bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.isThreadRunning
getsetprotected

◆ loop

virtual bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.loop
getset

◆ outputColorFormat

virtual ColorFormat OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.outputColorFormat
getset

◆ requestedVideoFilePath

virtual string OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.requestedVideoFilePath
getset

◆ shouldStopThread

virtual bool OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.shouldStopThread
getsetprotected

◆ timeoutFrameCount

virtual int OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.timeoutFrameCount
getset

◆ videoCapture

VideoCapture OpenCVForUnity.UnityUtils.Helper.VideoCaptureToMatHelper.videoCapture
getsetprotected

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