public Image <Bgr, byte> DrawContours(int threshold = 80, int choose = 0) { var contours = FindOfContours(threshold, choose); var ContoursImage = SourseImage.CopyBlank(); for (int i = 0; i < contours.Size; i++) { ContoursImage.Draw(contours[i].ToArray(), new Bgr(Color.GreenYellow), 2); // 1 - массив точек, 2 - цвет, 3 - толщина } return(ContoursImage); }
public Image <Bgr, byte> DrowSelectedPrimitives(int index, int threshold = 80) { var primitives = FindPrimitives(threshold);; var primitivesImage = SourseImage.CopyBlank(); for (int i = 0; i < primitives[index].ToArray().Length; i++) { primitivesImage.Draw(primitives[index].ToArray(), new Bgr(Color.Red), 3); } var result = SourseImage.Copy(); result = Sum(result, primitivesImage); return(result); }
public Image <Bgr, byte> DrawPrimitives(int choose, int area = 300, int threshold = 80, int minArea = 500, int minDistance = 250, int acTreshold = 36, int minRadius = 10, int maxRadius = 300, int choose_m = 0)//0 - Triangles, 1 - Rectangles, 2 - Circles, 3 - All of Finded { var PrimitivesImage = SourseImage.CopyBlank(); var listOfRect = FindRectangles(area, threshold, choose_m); var listOfTriangles = FindTriangles(minArea, threshold, choose_m); var listOfCircles = HoughtAlgoritm(minDistance, acTreshold, minRadius, maxRadius); switch (choose) { case 0: for (int i = 0; i < listOfTriangles.Count - 2; i++) { PrimitivesImage.Draw(new Triangle2DF(listOfTriangles[i][0], listOfTriangles[i][1], listOfTriangles[i][2]), new Bgr(Color.GreenYellow), 2); } break; case 1: for (int i = 0; i < listOfRect.Count; i++) { PrimitivesImage.Draw(CvInvoke.MinAreaRect(listOfRect[i].ToArray()), new Bgr(Color.GreenYellow), 2); } break; case 2: for (int i = 0; i < listOfCircles.Count; i++) { PrimitivesImage.Draw(listOfCircles[i], new Bgr(Color.GreenYellow), 2); } break; default: if (listOfTriangles.Count > 0) { for (int i = 0; i < listOfTriangles.Count; i++) { PrimitivesImage.Draw(new Triangle2DF(listOfTriangles[i][0], listOfTriangles[i][1], listOfTriangles[i][2]), new Bgr(Color.GreenYellow), 2); } } if (listOfRect.Count > 0) { for (int i = 0; i < listOfRect.Count; i++) { PrimitivesImage.Draw(CvInvoke.MinAreaRect(listOfRect[i]), new Bgr(Color.GreenYellow), 2); } } if (listOfCircles.Count > 0 && listOfCircles != null) { for (int i = 0; i < listOfCircles.Count; i++) { PrimitivesImage.Draw(listOfCircles[i], new Bgr(Color.GreenYellow), 2); } } break; } return(Sum(SourseImage, PrimitivesImage)); }