Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#中的EMGU CV将列表中的项目属性显示到列表框中_C#_Opencv_Emgucv_Hough Transform - Fatal编程技术网

C#中的EMGU CV将列表中的项目属性显示到列表框中

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

我已经使用HoughCircles对静态图像进行了检测,该方法自动检测圆的半径,以便绘制圆。目前我只能在文本框中逐个显示圆的半径,如下所示:

        #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());
        }