Почему моя веб-камера не транслирует видео в c #? - PullRequest
0 голосов
/ 29 июня 2019
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;

        }


    }
}

Это мой код, и я не могу заставить его работать.Все вроде нормально, я не могу отладить.Мой ImageBox не передает потоковое видео, просто показывая изображение.

1 Ответ

0 голосов
/ 30 июня 2019

Я нашел ответ. Благодарю вас!. Все :)

публичный частичный класс 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;
    }
...