本文整理汇总了C#中Emgu.DrawPolyline方法的典型用法代码示例。如果您正苦于以下问题:C# Emgu.DrawPolyline方法的具体用法?C# Emgu.DrawPolyline怎么用?C# Emgu.DrawPolyline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Emgu
的用法示例。
在下文中一共展示了Emgu.DrawPolyline方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessImage
public void ProcessImage(Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte> image) {
Emgu.CV.Image<Gray, byte> gray = image.Convert<Gray, byte>();
Emgu.CV.Image<Gray, byte> binary = new Image<Gray,byte>(image.Size);
CvInvoke.cvThreshold(gray, binary, 40, 255, THRESH.CV_THRESH_BINARY | THRESH.CV_THRESH_OTSU);
binary._Not();
Emgu.CV.Contour<System.Drawing.Point> contour_points = binary.FindContours();
MemStorage storage = new MemStorage();
Matrix<double> warp = new Matrix<double>(3, 3);
while (contour_points != null) {
Contour<Point> c = contour_points.ApproxPoly(contour_points.Perimeter * 0.05, storage);
double p = c.Perimeter;
if (c.Total == 4 && p > 300) {
PointF[] src = new PointF[] {
new PointF(c[0].X, c[0].Y),
new PointF(c[1].X, c[1].Y),
new PointF(c[2].X, c[2].Y),
new PointF(c[3].X, c[3].Y)};
CvInvoke.cvGetPerspectiveTransform(src, _dest, warp);
int flags = (int)INTER.CV_INTER_LINEAR + (int)WARP.CV_WARP_FILL_OUTLIERS;
CvInvoke.cvWarpPerspective(gray, _roi, warp, flags, new MCvScalar(0));
double min_error;
Orientation orient;
FindBestOrientation(out min_error, out orient);
if (min_error < 0.4) {
image.DrawPolyline(c.ToArray(), true, new Bgr(Color.Green), 2);
System.Console.WriteLine(min_error + " " + orient);
switch (orient) {
case Orientation.Degrees0:
image.Draw(new LineSegment2D(c[0], c[3]), new Bgr(System.Drawing.Color.Red), 2);
break;
case Orientation.Degrees90:
image.Draw(new LineSegment2D(c[1], c[0]), new Bgr(System.Drawing.Color.Red), 2);
break;
case Orientation.Degrees180:
image.Draw(new LineSegment2D(c[2], c[1]), new Bgr(System.Drawing.Color.Red), 2);
break;
case Orientation.Degrees270:
image.Draw(new LineSegment2D(c[3], c[2]), new Bgr(System.Drawing.Color.Red), 2);
break;
}
}
// 0 degrees
}
contour_points = contour_points.HNext;
}
}