【问题标题】:Emgu circle detection using a webcam使用网络摄像头进行 Emgu 圆圈检测
【发布时间】:2012-09-19 15:38:38
【问题描述】:

我正在尝试编写一个程序,当你把它放在网络摄像头前面时,它会检测一个圆圈。我知道圆形检测如何用于图像,但我不知道如何使用以下代码使其与网络摄像头流一起使用:

static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        ImageViewer viewer = new ImageViewer(); //create an image viewer
        Capture capture = new Capture(); //create a camera capture
        Application.Idle += new EventHandler(delegate(object sender, EventArgs e)
        {  //run this until application closed (close button click on image viewer)
            Image<Bgr, Byte> image = capture.QueryFrame();
            //MemStorage storage = new MemStorage();
            //Contour<Point> contours = image.FindContours();
           //Contour<Point> currentContour = contours.ApproxPoly(contours.Perimeter * 0.05, storage);
            viewer.Image = image; //draw the image obtained from camera
        });
        viewer.ShowDialog(); //show the image viewer
}

如您所见,我尝试在最里面的循环中使用 FindContours,但是当我尝试运行它时程序会冻结,所以我注释掉了该特定部分。谁能告诉我如何使用网络摄像头实现圆圈检测?

【问题讨论】:

    标签: webcam detection geometry emgucv


    【解决方案1】:

    可以使用HoughCircle方法进行圆检测

    
    Image gray = img.Convert().PyrDown().PyrUp();
    
    Gray cannyThreshold = new Gray(180);
    Gray cannyThresholdLinking = new Gray(120);
    Gray circleAccumulatorThreshold = new Gray(120);
    
    CircleF[] circles = gray.HoughCircles(
        cannyThreshold,
        circleAccumulatorThreshold,
        5.0, //Resolution of the accumulator used to detect centers of the circles
        10.0, //min distance 
        5, //min radius
        0 //max radius
        )[0]; //Get the circles from the first channel
    

    见方法HoughCircle

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多