本文整理汇总了C#中Mat.DrawContours方法的典型用法代码示例。如果您正苦于以下问题:C# Mat.DrawContours方法的具体用法?C# Mat.DrawContours怎么用?C# Mat.DrawContours使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat
的用法示例。
在下文中一共展示了Mat.DrawContours方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
Mat src = new Mat("TestImages/2013-12-27-09G37_TRB.jpg", LoadMode.Color);
src = src.Resize (new Size (420, 625));
Mat srcGrey = src.CvtColor(ColorConversion.BgrToGray);
Mat dst = new Mat ();
Point[][] contours;
Mat invertColour = new Mat (src.Rows, src.Cols, src.Type(), new Scalar(255, 255, 255) );
HiearchyIndex[] hierarchy;
Mat contoursLines = new Mat(src.Rows, src.Cols, src.Type());
// InputArray element = Cv2.GetStructuringElement (StructuringElementShape.Ellipse, new Size (16, 16));
// Mat thresh = srcGrey.Threshold (230, 255, ThresholdType.Binary).Dilate(element);
Mat thresh = srcGrey.Threshold (230, 255, ThresholdType.Binary);
Cv2.FindContours (thresh, out contours, out hierarchy, ContourRetrieval.Tree, ContourChain.ApproxSimple);
// Find center of mass in contour
Moments center = Cv2.Moments (contours [0]);
// Convert moment matrix to X/Y coords
int x = (int) (center.M10 / center.M00);
int y = (int) (center.M01 / center.M00);
src.Circle (new Point (x, y), 5, CvColor.CornflowerBlue, 2);
src.DrawContours (contours, 1, CvColor.Green, 2);
bool intersect = IsIntersecting (selector[0], selector[1], contours[1][0], contours[1][1]);
using (var orig = new Window ("src image", src))
{
orig.OnMouseCallback += new CvMouseCallback(MouseMove);
Cv2.WaitKey();
}
}