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.
Loading...
Searching...
No Matches
OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper Class Reference

WebCamTexture to mat helper. v 1.1.6. More...

Classes

class  ErrorUnityEvent
 

Public Types

enum  ColorFormat : int {
  GRAY = 0 ,
  RGB ,
  BGR ,
  RGBA ,
  BGRA
}
 
enum  ErrorCode : int {
  UNKNOWN = 0 ,
  CAMERA_DEVICE_NOT_EXIST ,
  CAMERA_PERMISSION_DENIED ,
  TIMEOUT
}
 

Public Member Functions

virtual bool DidUpdateThisFrame ()
 Indicates whether the video buffer of the frame has been updated.
 
virtual void Dispose ()
 Releases all resource used by the WebCamTextureToMatHelper object.
 
virtual Color32[] GetBufferColors ()
 Gets the buffer colors.
 
virtual Matrix4x4 GetCameraToWorldMatrix ()
 Returns the camera to world matrix.
 
virtual string GetDeviceName ()
 Returns the active camera device name.
 
virtual float GetFPS ()
 Returns the active camera framerate.
 
virtual int GetHeight ()
 Returns the active camera height.
 
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). Please do not dispose of the returned mat as it will be reused.
 
virtual Matrix4x4 GetProjectionMatrix ()
 Returns the projection matrix matrix.
 
virtual WebCamDevice GetWebCamDevice ()
 Returns the active WebcamDevice.
 
virtual WebCamTexture GetWebCamTexture ()
 Returns the active WebcamTexture.
 
virtual int GetWidth ()
 Returns the active camera width.
 
virtual void Initialize ()
 Initializes this instance.
 
virtual void Initialize (bool requestedIsFrontFacing, float requestedFPS=30f, bool rotate90Degree=false)
 Initializes this instance.
 
virtual void Initialize (int requestedWidth, int requestedHeight)
 Initializes this instance.
 
virtual void Initialize (string deviceName, int requestedWidth, int requestedHeight, bool requestedIsFrontFacing=false, float requestedFPS=30f, bool rotate90Degree=false)
 Initializes this instance.
 
virtual bool IsFrontFacing ()
 Indicates whether the active camera device is currently front facng.
 
virtual bool IsInitialized ()
 Indicates whether this instance has been initialized.
 
virtual bool IsPlaying ()
 Indicates whether the active camera is currently playing.
 
virtual void Pause ()
 Pauses the active camera.
 
virtual void Play ()
 Starts the camera.
 
virtual void Stop ()
 Stops the active camera.
 

Public Attributes

bool avoidAndroidFrontCameraLowLightIssue = false
 Indicates whether this instance avoids the front camera low light issue that occurs in only some Android devices (e.g. Google Pixel, Pixel2). Sets compulsorily the requestedFPS parameter to 15 (only when using the front camera), to avoid the problem of the WebCamTexture image becoming low light. https://forum.unity.com/threads/android-webcamtexture-in-low-light-only-some-models.520656/ https://forum.unity.com/threads/released-opencv-for-unity.277080/page-33#post-3445178.
 
UnityEvent onDisposed
 UnityEvent that is triggered when this instance is disposed.
 
ErrorUnityEvent onErrorOccurred
 UnityEvent that is triggered when this instance is error Occurred.
 
UnityEvent onInitialized
 UnityEvent that is triggered when this instance is initialized.
 

Protected Member Functions

virtual IEnumerator _Initialize ()
 Initializes this instance by coroutine.
 
virtual void CancelInitCoroutine ()
 Cancel Init Coroutine.
 
virtual int Channels (ColorFormat type)
 
virtual int ColorConversionCodes (ColorFormat srcType, ColorFormat dstType)
 
virtual void FlipMat (Mat mat, bool flipVertical, bool flipHorizontal)
 Flips the mat.
 
virtual IEnumerator hasUserAuthorizedCameraPermission ()
 Checks camera permission state by coroutine.
 
virtual IEnumerator OnApplicationFocus (bool hasFocus)
 
virtual void OnDestroy ()
 Raises the destroy event.
 
virtual void OnValidate ()
 
virtual void ReleaseResources ()
 To release the resources.
 
virtual void Update ()
 

Protected Attributes

bool _flipHorizontal = false
 Determines if flips horizontal.
 
bool _flipVertical = false
 Determines if flips vertically.
 
ColorFormat _outputColorFormat = ColorFormat.RGBA
 Select the output color format.
 
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.
 
bool _requestedIsFrontFacing = false
 Set whether to use the front facing camera.
 
int _requestedWidth = 640
 Set the width of camera.
 
bool _rotate90Degree = false
 Sets whether to rotate camera frame 90 degrees. (clockwise)
 
int _timeoutFrameCount = 1500
 The number of frames before the initialization process times out.
 
ColorFormat baseColorFormat = ColorFormat.RGBA
 The base color format.
 
Mat baseMat
 The base mat.
 
Color32[] colors
 The buffer colors.
 
Mat frameMat
 The frame mat.
 
bool hasInitDone = false
 Indicates whether this instance has been initialized.
 
IEnumerator initCoroutine
 The initialization coroutine.
 
bool isInitWaiting = false
 Indicates whether this instance is waiting for initialization to complete.
 
bool isScreenSizeChangeWaiting = false
 
Mat rotatedFrameMat
 The rotated frame mat.
 
int screenHeight
 The height of the screen.
 
ScreenOrientation screenOrientation
 The orientation of the screen.
 
int screenWidth
 The width of the screen.
 
WebCamDevice webCamDevice
 The active WebcamDevice.
 
WebCamTexture webCamTexture
 The active WebcamTexture.
 

Properties

virtual bool flipHorizontal [get, set]
 
virtual bool flipVertical [get, set]
 
virtual ColorFormat outputColorFormat [get, set]
 
virtual string requestedDeviceName [get, set]
 
virtual float requestedFPS [get, set]
 
virtual int requestedHeight [get, set]
 
virtual bool requestedIsFrontFacing [get, set]
 
virtual int requestedWidth [get, set]
 
virtual bool rotate90Degree [get, set]
 
virtual int timeoutFrameCount [get, set]
 

Detailed Description

WebCamTexture to mat helper. v 1.1.6.

By setting outputColorFormat to RGBA, processing that does not include extra color conversion is performed.

Deprecated
Use the WebCamTexture2MatHelper class instead.

Member Enumeration Documentation

◆ ColorFormat

Enumerator
GRAY 
RGB 
BGR 
RGBA 
BGRA 

◆ ErrorCode

Enumerator
UNKNOWN 
CAMERA_DEVICE_NOT_EXIST 
CAMERA_PERMISSION_DENIED 
TIMEOUT 

Member Function Documentation

◆ _Initialize()

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

Initializes this instance by coroutine.

◆ CancelInitCoroutine()

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

Cancel Init Coroutine.

◆ Channels()

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

◆ ColorConversionCodes()

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

◆ DidUpdateThisFrame()

virtual bool OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.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.WebCamTextureToMatHelper.Dispose ( )
virtual

Releases all resource used by the WebCamTextureToMatHelper object.

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

◆ FlipMat()

virtual void OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.FlipMat ( Mat mat,
bool flipVertical,
bool flipHorizontal )
protectedvirtual

Flips the mat.

Parameters
matMat.

◆ GetBufferColors()

virtual Color32[] OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.GetBufferColors ( )
virtual

Gets the buffer colors.

Returns
The buffer colors.

◆ GetCameraToWorldMatrix()

virtual Matrix4x4 OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.GetCameraToWorldMatrix ( )
virtual

Returns the camera to world matrix.

Returns
The camera to world matrix.

◆ GetDeviceName()

virtual string OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.GetDeviceName ( )
virtual

Returns the active camera device name.

Returns
The active camera device name.

◆ GetFPS()

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

Returns the active camera framerate.

Returns
The active camera framerate.

◆ GetHeight()

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

Returns the active camera height.

Returns
The active camera height.

◆ GetMat()

virtual Mat OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.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). Please do not dispose of the returned mat as it will be reused.

Returns
The mat of the current frame.

◆ GetProjectionMatrix()

virtual Matrix4x4 OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.GetProjectionMatrix ( )
virtual

Returns the projection matrix matrix.

Returns
The projection matrix.

◆ GetWebCamDevice()

virtual WebCamDevice OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.GetWebCamDevice ( )
virtual

Returns the active WebcamDevice.

Returns
The active WebcamDevice.

◆ GetWebCamTexture()

virtual WebCamTexture OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.GetWebCamTexture ( )
virtual

Returns the active WebcamTexture.

Returns
The active WebcamTexture.

◆ GetWidth()

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

Returns the active camera width.

Returns
The active camera width.

◆ hasUserAuthorizedCameraPermission()

virtual IEnumerator OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.hasUserAuthorizedCameraPermission ( )
protectedvirtual

Checks camera permission state by coroutine.

◆ Initialize() [1/4]

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

Initializes this instance.

◆ Initialize() [2/4]

virtual void OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.Initialize ( bool requestedIsFrontFacing,
float requestedFPS = 30f,
bool rotate90Degree = false )
virtual

Initializes this instance.

Parameters
requestedIsFrontFacingIf set to true requested to using the front camera.
requestedFPSRequested FPS.
rotate90DegreeIf set to true requested to rotate camera frame 90 degrees. (clockwise)

◆ Initialize() [3/4]

virtual void OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.Initialize ( int requestedWidth,
int requestedHeight )
virtual

Initializes this instance.

Parameters
requestedWidthRequested width.
requestedHeightRequested height.

◆ Initialize() [4/4]

virtual void OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.Initialize ( string deviceName,
int requestedWidth,
int requestedHeight,
bool requestedIsFrontFacing = false,
float requestedFPS = 30f,
bool rotate90Degree = false )
virtual

Initializes this instance.

Parameters
deviceNameDevice name.
requestedWidthRequested width.
requestedHeightRequested height.
requestedIsFrontFacingIf set to true requested to using the front camera.
requestedFPSRequested FPS.
rotate90DegreeIf set to true requested to rotate camera frame 90 degrees. (clockwise)

◆ IsFrontFacing()

virtual bool OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.IsFrontFacing ( )
virtual

Indicates whether the active camera device is currently front facng.

Returns
true, if the active camera device is front facng, false otherwise.

◆ IsInitialized()

virtual bool OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.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.WebCamTextureToMatHelper.IsPlaying ( )
virtual

Indicates whether the active camera is currently playing.

Returns
true, if the active camera is playing, false otherwise.

◆ OnApplicationFocus()

virtual IEnumerator OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.OnApplicationFocus ( bool hasFocus)
protectedvirtual

◆ OnDestroy()

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

Raises the destroy event.

◆ OnValidate()

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

◆ Pause()

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

Pauses the active camera.

◆ Play()

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

Starts the camera.

◆ ReleaseResources()

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

To release the resources.

◆ Stop()

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

Stops the active camera.

◆ Update()

virtual void OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.Update ( )
protectedvirtual

Member Data Documentation

◆ _flipHorizontal

bool OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper._flipHorizontal = false
protected

Determines if flips horizontal.

◆ _flipVertical

bool OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper._flipVertical = false
protected

Determines if flips vertically.

◆ _outputColorFormat

ColorFormat OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper._outputColorFormat = ColorFormat.RGBA
protected

Select the output color format.

◆ _requestedDeviceName

string OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper._requestedDeviceName = null
protected

Set the name of the camera device to use. (or device index number)

◆ _requestedFPS

float OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper._requestedFPS = 30f
protected

Set the frame rate of camera.

◆ _requestedHeight

int OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper._requestedHeight = 480
protected

Set the height of camera.

◆ _requestedIsFrontFacing

bool OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper._requestedIsFrontFacing = false
protected

Set whether to use the front facing camera.

◆ _requestedWidth

int OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper._requestedWidth = 640
protected

Set the width of camera.

◆ _rotate90Degree

bool OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper._rotate90Degree = false
protected

Sets whether to rotate camera frame 90 degrees. (clockwise)

◆ _timeoutFrameCount

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

The number of frames before the initialization process times out.

◆ avoidAndroidFrontCameraLowLightIssue

bool OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.avoidAndroidFrontCameraLowLightIssue = false

Indicates whether this instance avoids the front camera low light issue that occurs in only some Android devices (e.g. Google Pixel, Pixel2). Sets compulsorily the requestedFPS parameter to 15 (only when using the front camera), to avoid the problem of the WebCamTexture image becoming low light. https://forum.unity.com/threads/android-webcamtexture-in-low-light-only-some-models.520656/ https://forum.unity.com/threads/released-opencv-for-unity.277080/page-33#post-3445178.

◆ baseColorFormat

ColorFormat OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.baseColorFormat = ColorFormat.RGBA
protected

The base color format.

◆ baseMat

Mat OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.baseMat
protected

The base mat.

◆ colors

Color32 [] OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.colors
protected

The buffer colors.

◆ frameMat

Mat OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.frameMat
protected

The frame mat.

◆ hasInitDone

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

Indicates whether this instance has been initialized.

◆ initCoroutine

IEnumerator OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.initCoroutine
protected

The initialization coroutine.

◆ isInitWaiting

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

Indicates whether this instance is waiting for initialization to complete.

◆ isScreenSizeChangeWaiting

bool OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.isScreenSizeChangeWaiting = false
protected

◆ onDisposed

UnityEvent OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.onDisposed

UnityEvent that is triggered when this instance is disposed.

◆ onErrorOccurred

ErrorUnityEvent OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.onErrorOccurred

UnityEvent that is triggered when this instance is error Occurred.

◆ onInitialized

UnityEvent OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.onInitialized

UnityEvent that is triggered when this instance is initialized.

◆ rotatedFrameMat

Mat OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.rotatedFrameMat
protected

The rotated frame mat.

◆ screenHeight

int OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.screenHeight
protected

The height of the screen.

◆ screenOrientation

ScreenOrientation OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.screenOrientation
protected

The orientation of the screen.

◆ screenWidth

int OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.screenWidth
protected

The width of the screen.

◆ webCamDevice

WebCamDevice OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.webCamDevice
protected

The active WebcamDevice.

◆ webCamTexture

WebCamTexture OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.webCamTexture
protected

The active WebcamTexture.

Property Documentation

◆ flipHorizontal

virtual bool OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.flipHorizontal
getset

◆ flipVertical

virtual bool OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.flipVertical
getset

◆ outputColorFormat

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

◆ requestedDeviceName

virtual string OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.requestedDeviceName
getset

◆ requestedFPS

virtual float OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.requestedFPS
getset

◆ requestedHeight

virtual int OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.requestedHeight
getset

◆ requestedIsFrontFacing

virtual bool OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.requestedIsFrontFacing
getset

◆ requestedWidth

virtual int OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.requestedWidth
getset

◆ rotate90Degree

virtual bool OpenCVForUnity.UnityUtils.Helper.WebCamTextureToMatHelper.rotate90Degree
getset

◆ timeoutFrameCount

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

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