如何在EmguCV中围绕轮廓绘制最小的圆圈? FindContours()方法返回一组点。但要绘制圆圈,它要求获得pointf。有没有解决这个问题?感谢。
答案 0 :(得分:0)
是的,有办法。您只需要将Contour转换为PointF数组,如下所示:
for (var contour = binaryImage.FindContours(CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE,
RETR_TYPE.CV_RETR_CCOMP, mem);
contour != null;
contour = contour.HNext)
{
//assuming you have a way of getting the index of
//point you wanted to extract from the current contour
var index = 0;
PointF[] pointfs = Array.ConvertAll(contour.ToArray(),
input => new PointF(input.X, input.Y));
//just an example
var circle = new CircleF(pointfs[index], 2.0f);
}