简体   繁体   中英

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. I need to close webcam by clicking 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.

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.QueryFrame(); Application.Idle -= FrameGrabber; grabber.Dispose();`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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