C#中的EMGU CV将列表中的项目属性显示到列表框中
我已经使用HoughCircles对静态图像进行了检测,该方法自动检测圆的半径,以便绘制圆。目前我只能在文本框中逐个显示圆的半径,如下所示:C#中的EMGU CV将列表中的项目属性显示到列表框中,c#,opencv,emgucv,hough-transform,C#,Opencv,Emgucv,Hough Transform,我已经使用HoughCircles对静态图像进行了检测,该方法自动检测圆的半径,以便绘制圆。目前我只能在文本框中逐个显示圆的半径,如下所示: #region circle detection Stopwatch watch = Stopwatch.StartNew(); double cannyThreshold = 100.0; double circleAccumulatorThreshold = 80; Cir
#region circle detection
Stopwatch watch = Stopwatch.StartNew();
double cannyThreshold = 100.0;
double circleAccumulatorThreshold = 80;
CircleF[] circles = CvInvoke.HoughCircles(uimage, HoughType.Gradient, 2.0, 20.0, cannyThreshold, circleAccumulatorThreshold, 5);
watch.Stop();
msgBuilder.Append(String.Format("Hough circles - {0} ms; ", watch.ElapsedMilliseconds));
#endregion
imgOriginal.Image = img;
this.Text = msgBuilder.ToString();
#region draw circles
Image<Bgr, Byte> circleImage = img.CopyBlank();
foreach (CircleF circle in circles)
{
circleImage.Draw(circle, new Bgr(Color.Brown), 2);
}
imgDetect.Image = circleImage;
txtDetect.Text=圆[0]。半径.ToString()
txtDetect1.Text=圆[1].半径.ToString()
当我尝试将其转换为列表时,会出现以下错误:
无法将类型“Emgu.CV.Structure.CircleF[]”隐式转换为“System.Collections.Generic.List”
相关代码如下:
#region circle detection
Stopwatch watch = Stopwatch.StartNew();
double cannyThreshold = 100.0;
double circleAccumulatorThreshold = 80;
CircleF[] circles = CvInvoke.HoughCircles(uimage, HoughType.Gradient, 2.0, 20.0, cannyThreshold, circleAccumulatorThreshold, 5);
watch.Stop();
msgBuilder.Append(String.Format("Hough circles - {0} ms; ", watch.ElapsedMilliseconds));
#endregion
imgOriginal.Image = img;
this.Text = msgBuilder.ToString();
#region draw circles
Image<Bgr, Byte> circleImage = img.CopyBlank();
foreach (CircleF circle in circles)
{
circleImage.Draw(circle, new Bgr(Color.Brown), 2);
}
imgDetect.Image = circleImage;
#区域圆检测
秒表=Stopwatch.StartNew();
双筒保持=100.0;
双圈阈值=80;
CircleF[]circles=CvInvoke.HoughCircles(uimage,HoughType.Gradient,2.0,20.0,cannyThreshold,CircleAcumeratorThreshold,5);
看,停;
追加(String.Format(“Hough circles-{0}ms;”,watch.elapsedmillesons));
#端区
imgOriginal.Image=img;
this.Text=msgBuilder.ToString();
#区域画圆
Image circleImage=img.CopyBlank();
foreach(圆圈中的圆圈)
{
圆圈图像绘制(圆圈,新Bgr(颜色为棕色),2);
}
imgDetect.Image=圆形图像;
非常感谢您的帮助。这是一个非常简单的解决方案:
lstRadius.Items.Clear();
foreach (CircleF circle in circles)
{
circleImage.Draw(circle, new Bgr(Color.Brown), 2);
lstRadius.Items.Add(circle.Radius.ToString());
}