在opencv中关闭相机

时间:2011-08-21 10:14:53

标签: c# winforms opencv

如何更改此代码,所以当我点击其他按钮 - CloseCamera_Button时,我可以禁用cam。

 private void Camera_Button_Click(object sender, EventArgs e)
        {
            using (CvCapture cap = CvCapture.FromCamera(0))
             using (CvWindow w = new CvWindow("Edges"))
            {
                while (CvWindow.WaitKey(10) < 0)

                {
                    using (IplImage src = cap.QueryFrame())
                    {
                        StreamingWindow.Image = BitmapConverter.ToBitmap(cap.QueryFrame());
                    }
                }
            }
        }

我需要删除CVwindow,所以代码看起来应该是这样的:

 private void Camera_Button_Click(object sender, EventArgs e)
            {
                using (CvCapture cap = CvCapture.FromCamera(0))

                {
                    while (!CloseCamera_Button pressed)

                    {
                        using (IplImage src = cap.QueryFrame())
                        {
                            StreamingWindow.Image = BitmapConverter.ToBitmap(cap.QueryFrame());
                        }
                    }
                }
            }

0 个答案:

没有答案