【发布时间】:2017-12-12 18:16:10
【问题描述】:
我正在使用 Visual Studio 2015、OpenCV.3 和 EmguCV.3。 我的代码如下所示,结果如图所示。我知道问题是 HoughCircles 函数的输入值,但我不知道哪些输入适合这张图片。感谢您的帮助。
Image<Gray, byte> OriginalImage = new Image<Gray, byte>(Openfile.FileName);
Image<Gray, byte> ResizedImage = OriginalImage.Resize(OriginalImage.Width / 2, OriginalImage.Height / 2, Emgu.CV.CvEnum.Inter.Cubic);
//********** Convert Image to Binary
Image<Gray, byte> smoothImg =
ResizedImage.SmoothGaussian(5);
smoothImg._Erode(5);
smoothImg._Dilate(5);
Image<Gray, byte> BinaryImage =
smoothImg.ThresholdBinary(new Gray(20), new Gray(255));
//********** Find Circles
Image<Rgb, byte> ROIImgScaledCircles = ROIImgScaled.Convert<Rgb, byte>();
CircleF[] circles = smoothImg.HoughCircles(
new Gray(180),//cannyThreshold
new Gray(60),//circleAccumulatorThreshold
2.0, //dp:Resolution of the accumulator used to detect centers of the circles
10.0, //min distance
10, //min radius
128 //max radius
)[0]; //Get the circles from the first channel
foreach (CircleF cir in circles)
{
ROIImgScaledCircles.Draw(cir, new Rgb(235, 20, 30), 1);
}
pbxCircles.Image = ROIImgScaledCircles.ToBitmap();
原图:
创建的圈子:
【问题讨论】:
-
可以提供原图吗?我猜你希望有 2 个圈子?
-
@SimonMourier 我编辑了问题并添加了原始图像。实际上是的,我希望有 2 个圆圈。
-
我使用 opencvsharp(与 c++/python 示例非常接近),而不是 emgucv,你可以吗?
标签: visual-studio emgucv opencv3.0