OpenCV for Unity 2.6.3
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.
Loading...
Searching...
No Matches
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 {
  GRAY = 0 , RGB , BGR , RGBA ,
  BGRA
}
 
enum  ErrorCode : int { UNKNOWN = 0 , VIDEO_FILE_NOT_EXIST , VIDEO_FILE_CANT_OPEN , TIMEOUT }
 

Public Member Functions

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

Public Attributes

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

Protected Member Functions

virtual void OnValidate ()
 
virtual void LateUpdate ()
 
virtual void ReadFrame ()
 
virtual void OnDestroy ()
 Raises the destroy event.
 
virtual IEnumerator _Initialize ()
 Initializes this instance by coroutine.
 
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.
 
virtual void ReleaseResources ()
 To release the resources.
 

Protected Attributes

string _requestedVideoFilePath = string.Empty
 Set the video file path.
 
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.
 
ColorFormat _outputColorFormat = ColorFormat.BGR
 Select the output color format.
 
int _timeoutFrameCount = 1500
 The number of frames before the initialization process times out.
 
bool _loop = true
 Indicates whether to play this video in a loop.
 
System.Object videoCaptureLockObject = new System.Object()
 The VideoCapture.
 
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.
 
Mat baseMat
 The base mat.
 
System.Object imageBufferMatLockObject = new System.Object()
 The image buffer mat.
 
Mat _imageBufferMat
 
ColorFormat baseColorFormat = ColorFormat.BGR
 The base color format.
 
bool isInitWaiting = false
 Indicates whether this instance is waiting for initialization to complete.
 
bool hasInitDone = false
 Indicates whether this instance has been initialized.
 
IEnumerator initCoroutine
 The initialization coroutine.
 
IEnumerator getFilePathCoroutine
 The get file path coroutine.
 
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: