OpenCV for Unity 3.0.0
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/4.12.0/index.html ) for the details of the argument of the method.
Loading...
Searching...
No Matches
OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper Class Reference

A helper component for optimizing image processing in Unity by managing frame skipping and downscaling operations. More...

Public Member Functions

virtual void Dispose ()
 
virtual Mat GetDownScaleMat (Mat originalMat)
 Gets the mat that downscaled the original mat. if downscaleRatio == 1 , return originalMat.
 
virtual bool IsCurrentFrameSkipped ()
 Indicates whether the current frame is skipped.
 
virtual KeyPoint RestoreOriginalSizeKeyPoint (KeyPoint downscaledKeyPoint)
 Restores the original size of the KeyPoint based on the downscale ratio.
 
virtual MatOfKeyPoint RestoreOriginalSizeMatOfKeyPoint (MatOfKeyPoint downscaledKeyPoints)
 Restores the original size of the MatOfKeyPoint based on the downscale ratio.
 
virtual MatOfPoint RestoreOriginalSizeMatOfPoint (MatOfPoint downscaledPoints)
 Restores the original size of the MatOfPoint based on the downscale ratio.
 
virtual MatOfPoint2f RestoreOriginalSizeMatOfPoint2f (MatOfPoint2f downscaledPoints)
 Restores the original size of the MatOfPoint2f based on the downscale ratio.
 
virtual MatOfPoint3 RestoreOriginalSizeMatOfPoint3 (MatOfPoint3 downscaledPoints)
 Restores the original size of the MatOfPoint3 based on the downscale ratio.
 
virtual MatOfPoint3f RestoreOriginalSizeMatOfPoint3f (MatOfPoint3f downscaledPoints)
 Restores the original size of the MatOfPoint3f based on the downscale ratio.
 
virtual MatOfRect RestoreOriginalSizeMatOfRect (MatOfRect downscaledRects)
 Restores the original size of the MatOfRect based on the downscale ratio.
 
virtual MatOfRect2d RestoreOriginalSizeMatOfRect2d (MatOfRect2d downscaledRects)
 Restores the original size of the MatOfRect2d based on the downscale ratio.
 
virtual MatOfRotatedRect RestoreOriginalSizeMatOfRotatedRect (MatOfRotatedRect downscaledRects)
 Restores the original size of the MatOfRotatedRect based on the downscale ratio.
 
virtual Point RestoreOriginalSizePoint (Point downscaledPoint)
 Restores the original size of the Point based on the downscale ratio.
 
virtual Point3 RestoreOriginalSizePoint3 (Point3 downscaledPoint)
 Restores the original size of the Point3 based on the downscale ratio.
 
virtual Rect RestoreOriginalSizeRect (Rect downscaledRect)
 Restores the original size of the Rect based on the downscale ratio.
 
virtual Rect2d RestoreOriginalSizeRect2d (Rect2d downscaledRect)
 Restores the original size of the Rect2d based on the downscale ratio.
 
virtual RotatedRect RestoreOriginalSizeRotatedRect (RotatedRect downscaledRect)
 Restores the original size of the RotatedRect based on the downscale ratio.
 

Protected Member Functions

virtual void OnDestroy ()
 
virtual void OnValidate ()
 

Protected Attributes

Mat _downScaleFrameMat
 The downscale frame mat.
 
float _downscaleRatio = 2f
 
int _frameCount = 0
 The frame count.
 
int _frameSkippingRatio = 2
 

Properties

virtual float downscaleRatio [get, set]
 The downscale ratio.
 
virtual int frameSkippingRatio [get, set]
 The frame skipping ratio.
 

Detailed Description

A helper component for optimizing image processing in Unity by managing frame skipping and downscaling operations.

The ImageOptimizationHelper class provides utilities to enhance performance during image processing tasks. It includes features such as:

  • Downscaling images to reduce computational load
  • Skipping frames to optimize processing frequency

This class is particularly useful when working with high-resolution images or real-time processing where performance is a priority.

Attach this component to a GameObject to enable image optimization:

// Example usage of the ImageOptimizationHelper component
ImageOptimizationHelper imageHelper = gameObject.AddComponent<ImageOptimizationHelper>();
imageHelper.downscaleRatio = 2.0f;
imageHelper.frameSkippingRatio = 3;
// Check if the current frame should be skipped
if (!imageHelper.IsCurrentFrameSkipped())
{
// Perform operations on the downscaled image
Mat optimizedMat = imageHelper.GetDownScaleMat(originalMat);
}
n-dimensional dense array class
Definition Mat_ValueTuple.cs:11
A helper component for optimizing image processing in Unity by managing frame skipping and downscalin...
Definition ImageOptimizationHelper.cs:42
virtual Mat GetDownScaleMat(Mat originalMat)
Gets the mat that downscaled the original mat. if downscaleRatio == 1 , return originalMat.
Definition ImageOptimizationHelper.cs:111
virtual bool IsCurrentFrameSkipped()
Indicates whether the current frame is skipped.
Definition ImageOptimizationHelper.cs:92

Member Function Documentation

◆ Dispose()

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

◆ GetDownScaleMat()

virtual Mat OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.GetDownScaleMat ( Mat originalMat)
virtual

Gets the mat that downscaled the original mat. if downscaleRatio == 1 , return originalMat.

Please do not dispose of the returned mat as it will be reused.

Returns
The downscale mat.
Parameters
originalMatOriginal mat.

◆ IsCurrentFrameSkipped()

virtual bool OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.IsCurrentFrameSkipped ( )
virtual

Indicates whether the current frame is skipped.

Returns
true, if the current frame is skipped, false otherwise.

◆ OnDestroy()

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

◆ OnValidate()

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

◆ RestoreOriginalSizeKeyPoint()

virtual KeyPoint OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.RestoreOriginalSizeKeyPoint ( KeyPoint downscaledKeyPoint)
virtual

Restores the original size of the KeyPoint based on the downscale ratio.

Parameters
downscaledPointThe detected keyooint in the downscaled image.
Returns
A new KeyPoint adjusted to the original image size.

◆ RestoreOriginalSizeMatOfKeyPoint()

virtual MatOfKeyPoint OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.RestoreOriginalSizeMatOfKeyPoint ( MatOfKeyPoint downscaledKeyPoints)
virtual

Restores the original size of the MatOfKeyPoint based on the downscale ratio.

Parameters
downscaledKeyPointsThe MatOfKeyPoint containing the detected keypoints in the downscaled image.
Returns
A new MatOfKeyPoint with the keypoints adjusted to the original image size.

◆ RestoreOriginalSizeMatOfPoint()

virtual MatOfPoint OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.RestoreOriginalSizeMatOfPoint ( MatOfPoint downscaledPoints)
virtual

Restores the original size of the MatOfPoint based on the downscale ratio.

Parameters
downscaledPointsThe MatOfPoint containing the detected points in the downscaled image.
Returns
A new MatOfPoint with the points adjusted to the original image size.

◆ RestoreOriginalSizeMatOfPoint2f()

virtual MatOfPoint2f OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.RestoreOriginalSizeMatOfPoint2f ( MatOfPoint2f downscaledPoints)
virtual

Restores the original size of the MatOfPoint2f based on the downscale ratio.

Parameters
downscaledPointsThe MatOfPoint2f containing the detected points in the downscaled image.
Returns
A new MatOfPoint2f with the points adjusted to the original image size.

◆ RestoreOriginalSizeMatOfPoint3()

virtual MatOfPoint3 OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.RestoreOriginalSizeMatOfPoint3 ( MatOfPoint3 downscaledPoints)
virtual

Restores the original size of the MatOfPoint3 based on the downscale ratio.

Parameters
downscaledPointsThe MatOfPoint3 containing the detected points in the downscaled image.
Returns
A new MatOfPoint3 with the points adjusted to the original image size.

◆ RestoreOriginalSizeMatOfPoint3f()

virtual MatOfPoint3f OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.RestoreOriginalSizeMatOfPoint3f ( MatOfPoint3f downscaledPoints)
virtual

Restores the original size of the MatOfPoint3f based on the downscale ratio.

Parameters
downscaledPointsThe MatOfPoint3f containing the detected points in the downscaled image.
Returns
A new MatOfPoint3f with the points adjusted to the original image size.

◆ RestoreOriginalSizeMatOfRect()

virtual MatOfRect OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.RestoreOriginalSizeMatOfRect ( MatOfRect downscaledRects)
virtual

Restores the original size of the MatOfRect based on the downscale ratio.

Parameters
downscaledRectsThe MatOfRect containing the detected rectangles in the downscaled image.
Returns
A new MatOfRect with the rectangles adjusted to the original image size.

◆ RestoreOriginalSizeMatOfRect2d()

virtual MatOfRect2d OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.RestoreOriginalSizeMatOfRect2d ( MatOfRect2d downscaledRects)
virtual

Restores the original size of the MatOfRect2d based on the downscale ratio.

Parameters
downscaledRectsThe MatOfRect2d containing the detected rectangles in the downscaled image.
Returns
A new MatOfRect2d with the rectangles adjusted to the original image size.

◆ RestoreOriginalSizeMatOfRotatedRect()

virtual MatOfRotatedRect OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.RestoreOriginalSizeMatOfRotatedRect ( MatOfRotatedRect downscaledRects)
virtual

Restores the original size of the MatOfRotatedRect based on the downscale ratio.

Parameters
downscaledRectsThe MatOfRotatedRect containing the detected rectangles in the downscaled image.
Returns
A new MatOfRotatedRect with the rectangles adjusted to the original image size.

◆ RestoreOriginalSizePoint()

virtual Point OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.RestoreOriginalSizePoint ( Point downscaledPoint)
virtual

Restores the original size of the Point based on the downscale ratio.

Parameters
downscaledPointThe detected point in the downscaled image.
Returns
A new Point adjusted to the original image size.

◆ RestoreOriginalSizePoint3()

virtual Point3 OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.RestoreOriginalSizePoint3 ( Point3 downscaledPoint)
virtual

Restores the original size of the Point3 based on the downscale ratio.

Parameters
downscaledPointThe detected point in the downscaled image.
Returns
A new Point3 adjusted to the original image size.

◆ RestoreOriginalSizeRect()

virtual Rect OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.RestoreOriginalSizeRect ( Rect downscaledRect)
virtual

Restores the original size of the Rect based on the downscale ratio.

Parameters
downscaledRectThe detected rectangle in the downscaled image.
Returns
A new Rect adjusted to the original image size.

◆ RestoreOriginalSizeRect2d()

virtual Rect2d OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.RestoreOriginalSizeRect2d ( Rect2d downscaledRect)
virtual

Restores the original size of the Rect2d based on the downscale ratio.

Parameters
downscaledRectThe detected rectangle in the downscaled image.
Returns
A new Rect2d adjusted to the original image size.

◆ RestoreOriginalSizeRotatedRect()

virtual RotatedRect OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.RestoreOriginalSizeRotatedRect ( RotatedRect downscaledRect)
virtual

Restores the original size of the RotatedRect based on the downscale ratio.

Parameters
downscaledRectThe detected rectangle in the downscaled image.
Returns
A new RotatedRect adjusted to the original image size.

Member Data Documentation

◆ _downScaleFrameMat

Mat OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper._downScaleFrameMat
protected

The downscale frame mat.

◆ _downscaleRatio

float OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper._downscaleRatio = 2f
protected

◆ _frameCount

int OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper._frameCount = 0
protected

The frame count.

◆ _frameSkippingRatio

int OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper._frameSkippingRatio = 2
protected

Property Documentation

◆ downscaleRatio

virtual float OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.downscaleRatio
getset

The downscale ratio.

◆ frameSkippingRatio

virtual int OpenCVForUnity.UnityUtils.Helper.ImageOptimizationHelper.frameSkippingRatio
getset

The frame skipping ratio.


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