当前位置: 首页>>代码示例>>C#>>正文


C# Mat.release方法代码示例

本文整理汇总了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 ();
        }
开发者ID:ygx2011,项目名称:OpenCVForUnity,代码行数:50,代码来源:HandPoseEstimationSample.cs


注:本文中的Mat.release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。