Esempio n. 1
0
        private void btn_playPause_Click(object sender, EventArgs e)
        {
            i++;
            if (i % 2 == 0)
            {
                this.btn_playPause.Image = ((System.Drawing.Image)(Properties.Resources.playIcon));

                btn_capImage.Enabled = false;
                videoSource.SignalToStop();
                videoSource.WaitForStop();
                videoSource.Stop();
            }
            else
            {
                new Thread(() => {
                    Thread.CurrentThread.IsBackground = true;
                    btn_capImage.Enabled     = true;
                    videoSource.Login        = camUsername;
                    videoSource.Password     = camPassword;
                    this.btn_playPause.Image = ((System.Drawing.Image)(Properties.Resources.pauseIcon));
                    videoSource.NewFrame    += new NewFrameEventHandler(video_NewFrame);
                    videoSource.Start();
                }).Start();
            }
        }
Esempio n. 2
0
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            videoStream.SignalToStop();
            Console.WriteLine("Disconnecting from {0}", videoStream.Source);
            videoStream.WaitForStop();

            base.OnClosing(e);
        }
Esempio n. 3
0
        private void StopVideo(int cam)
        {
            switch (cam)
            {
            case 0:
                vspTarget.SignalToStop();
                vspTarget.WaitForStop();
                videoSource.SignalToStop();
                videoSource.WaitForStop();
                break;

            case 1:
            case 2:
            case 3:
                vspTarget.SignalToStop();
                vspTarget.WaitForStop();
                stream.SignalToStop();
                stream.WaitForStop();
                break;
            }
            btnCapture.Text    = "Start";
            capVideoInProgress = false;
            cmbCamera.Enabled  = true;
        }
Esempio n. 4
0
        private void StartVideo(int cam)
        {
            switch (cam)
            {
            case 0:
                if (videoDevices.Count == 0)
                {
                    throw new Exception("No USB Camera available");
                }
                if (videoSource != null)
                {
                    videoSource.WaitForStop();
                }
                videoSource           = new VideoCaptureDevice(videoDevices[0].MonikerString); //local USB
                vspTarget.VideoSource = videoSource;
                vspTarget.Start();
                btnCapture.Text    = "Stop";
                capVideoInProgress = true;
                cmbCamera.Enabled  = false;
                break;

            case 1:
                //if (!isPingable(txtNetworkTables.Text)) throw new Exception("Camera is not available");
                if (stream != null)
                {
                    stream.WaitForStop();
                }
                stream = new MJPEGStream("http://" + txtNetworkTables.Text + ":1181/?action=stream");
                vspTarget.VideoSource = stream;
                vspTarget.Start();
                btnCapture.Text    = "Stop";
                capVideoInProgress = true;
                cmbCamera.Enabled  = false;
                break;

            case 2:
                //if (!isPingable(txtNetworkTables.Text)) throw new Exception("Camera is not available");
                if (stream != null)
                {
                    stream.WaitForStop();
                }
                stream = new MJPEGStream("http://" + txtNetworkTables.Text + ":1182/?action=stream");
                vspTarget.VideoSource = stream;
                vspTarget.Start();
                btnCapture.Text    = "Stop";
                capVideoInProgress = true;
                cmbCamera.Enabled  = false;
                break;

            case 3:
                //if (!isPingable(txtIPCamera.Text)) throw new Exception("Camera is not available");
                if (stream != null)
                {
                    stream.WaitForStop();
                }
                stream = new MJPEGStream("http://" + txtIPCamera.Text + "/mjpg/video.mjpg");
                vspTarget.VideoSource = stream;
                vspTarget.Start();
                btnCapture.Text    = "Stop";
                capVideoInProgress = true;
                cmbCamera.Enabled  = false;
                break;
            }
        }