0
public partial class Form1 : Form
    {


        public Form1()
        {
            InitializeComponent();
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            VideoCapture capture = new VideoCapture();
            var img = capture.QueryFrame();

            imageBox1.Image = img;

        }


    }
}

This is my code and I can't seem to make it work. Everything seems fine, I am unable to Debug. My ImageBox is not streaming a video just showing an image.

Shiva
  • 6,677
  • 4
  • 36
  • 61
  • Please do not post screenshots of your code (something to read: [Why not upload images of code on SO when asking a question?](https://meta.stackoverflow.com/a/285557/2819245), [An image of your code is not helpful](http://idownvotedbecau.se/imageofcode)). Rather, **edit** your question and add the code as text (code-formatted; the edit form of StackOverflow possesses an icon toolbar with an icon allowing you to format text as code) directly to your question. –  Jun 29 '19 at 16:21
  • Looks like you just capture one frame on button click – vik_78 Jun 29 '19 at 16:23
  • @vik_78 Can you help me? – Tasneem Khan Jun 29 '19 at 16:31
  • 2
    Try the answer given here: [C# VideoCapture](https://stackoverflow.com/questions/49300510/visual-studio-c-sharp-videocapture) – rad_ Jun 29 '19 at 16:46

1 Answers1

0

I found the answer. Thank You!. Everyone :)

public partial class Form1 : Form {

    bool _streaming;
    VideoCapture _capture;

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        _streaming = false;
        _capture = new VideoCapture();


    }
    private void Button2_Click(object sender, EventArgs e)
    {
        if (_streaming == false)
        {
            //Start streaming
            Application.Idle += streaming;
            button2.Text = "Stop Streaming";

        }
        else
        {
            Application.Idle -= streaming;
            button2.Text = "Start Streaming";

        }
        _streaming = !_streaming;
    }

    private void streaming(object sender, EventArgs e)
    {

        var img = _capture.QueryFrame();
        imageBox2.Image = img;


    }

    private void Button1_Click(object sender, EventArgs e)
    {
        imageBox1.Image = imageBox2.Image;
    }