简体   繁体   English

如何在 C# 程序中停止网络摄像头流媒体?

[英]How to stop webcam streaming in C# program?

    private void button1_Click(object sender, EventArgs e)
    {

       cap = new Capture();
        Application.Idle += new EventHandler(showFromCam);
        button1.Hide();
    }

    private void button2_Click(object sender, EventArgs e)
    {

        button1.Show();
    }

Using above code, I get webcam streaming into my application by clicking on button1.使用上面的代码,我通过单击 button1 将网络摄像头流式传输到我的应用程序中。 I need to close webcam by clicking button2.我需要通过单击 button2 来关闭网络摄像头。 Can anybody suggest any method to do it?有人可以建议任何方法吗? Thanks.谢谢。

I'm in the similar problem and I found a solution of my problem.我遇到了类似的问题,我找到了解决问题的方法。 You should call stop() and dispose() method.您应该调用stop()dispose()方法。

private void button2_Click(object sender, EventArgs e)
{
    // stop the camera
    cap.Stop();
    cap.Dispose(); 

    button1.Show();
}

I Think You should use grabber = new Capture();我认为你应该使用grabber = new Capture(); grabber.QueryFrame();抓取器.QueryFrame(); Application.Idle -= FrameGrabber; grabber.Dispose();`抓取器.处理();`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM