示例#1
0
        public (Mat, OpenCvSharp.Point) ProcessContours(ref Mat imgPreContours, ref Mat imgGrayscale, ref System.Drawing.Point actuatorPositionPixels)
        {
            // Find all contours from image
            allContours = IPCore.FindAllContours(ref imgPreContours);

            if (allContours.Count() > 0)
            {
                // Get the contours that has the largest area
                largestContourArea = IPCore.FindLargestContourArea(ref imgGrayscale, ref allContours);

                // Get largest contour's area center point imgPreContours
                OpenCvSharp.Point contourCenter = IPCore.FindContourCenter(ref imgPreContours, largestContourArea);

                // Put center coordinates on image and return it
                return(IPCore.ComposeImageDTC(ref imgGrayscale, ref largestContourArea, ref contourCenter, ref actuatorPositionPixels), contourCenter);
            }
            else
            {
                // Return the grayscale image if no contours were found
                return(imgGrayscale, new OpenCvSharp.Point(int.MinValue, int.MinValue));
            }
        }