我正在尝试编写一个程序,当您将它放在网络摄像头前时检测一个圆圈。我知道圆形检测如何用于图像,但我不知道如何使用以下代码使其与网络摄像头流一起使用:
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,但是当我尝试运行它时程序只是冻结了,所以我注释掉了那个特定的部分。谁能告诉我如何使用网络摄像头实现圆圈检测?