|
- public static void InnerCircle(Mat M_RectRegionFill, out int Row, out int Column, out double Radius)
- {
- Row = 0;
- Column = 0;
- Radius = 0.0;
- Mat dt = new Mat();
- Cv2.DistanceTransform(M_RectRegionFill, dt, DistanceTypes.L2, DistanceMaskSize.Mask3); // 需要M_RectRegionFill
- double min_val = 0;
- double max_val = 0;
- OpenCvSharp.Point minloc;
- OpenCvSharp.Point maxloc;
- Cv2.MinMaxLoc(dt, out min_val, out max_val, out minloc, out maxloc);
- Radius = (Math.Abs(max_val)); //对最大值求绝对值,即为内接圆半径
- Row = maxloc.Y;
- Column = maxloc.X;
- //Mat Src = new Mat(M_RectRegionFill.Height, M_RectRegionFill.Width, M_RectRegionFill.Type(), Scalar.Black);
- //Cv2.Circle(Src, maxloc.X, maxloc.Y, Radius, Scalar.White, 3, LineTypes.Link8, 0);
- //return Src;
- dt.Dispose();
- }
复制代码 可参考:【1】OpenCVSharp 小练习 最大内接圆_using (mat src2 = cv2.imread(-CSDN博客
【2】如何寻找已知轮廓的最大内接圆 - jsxyhelu - 博客园 (cnblogs.com)
【3】如何寻找已知轮廓的最大内接圆-CSDN博客
|
|