本文整理汇总了C#中Mat.release方法的典型用法代码示例。如果您正苦于以下问题:C# Mat.release方法的具体用法?C# Mat.release怎么用?C# Mat.release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat
的用法示例。
在下文中一共展示了Mat.release方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: onTouch
/// <summary>
/// Ons the touch.
/// </summary>
/// <param name="touchPoint">Touch point.</param>
public void onTouch(Mat rgbaMat, Point touchPoint)
{
int cols = rgbaMat.cols ();
int rows = rgbaMat.rows ();
int x = (int)touchPoint.x;
int y = (int)touchPoint.y;
// Debug.Log ("Touch image coordinates: (" + x + ", " + y + ")");
if ((x < 0) || (y < 0) || (x > cols) || (y > rows))
return;
OpenCVForUnity.Rect touchedRect = new OpenCVForUnity.Rect ();
touchedRect.x = (x > 5) ? x - 5 : 0;
touchedRect.y = (y > 5) ? y - 5 : 0;
touchedRect.width = (x + 5 < cols) ? x + 5 - touchedRect.x : cols - touchedRect.x;
touchedRect.height = (y + 5 < rows) ? y + 5 - touchedRect.y : rows - touchedRect.y;
Mat touchedRegionRgba = rgbaMat.submat (touchedRect);
Mat touchedRegionHsv = new Mat ();
Imgproc.cvtColor (touchedRegionRgba, touchedRegionHsv, Imgproc.COLOR_RGB2HSV_FULL);
// Calculate average color of touched region
blobColorHsv = Core.sumElems (touchedRegionHsv);
int pointCount = touchedRect.width * touchedRect.height;
for (int i = 0; i < blobColorHsv.val.Length; i++)
blobColorHsv.val [i] /= pointCount;
//blobColorRgba = converScalarHsv2Rgba (blobColorHsv);
// Debug.Log ("Touched rgba color: (" + mBlobColorRgba.val [0] + ", " + mBlobColorRgba.val [1] +
// ", " + mBlobColorRgba.val [2] + ", " + mBlobColorRgba.val [3] + ")");
detector.setHsvColor (blobColorHsv);
Imgproc.resize (detector.getSpectrum (), spectrumMat, SPECTRUM_SIZE);
isColorSelected = true;
touchedRegionRgba.release ();
touchedRegionHsv.release ();
}