コード例 #1
0
ファイル: MainForm.cs プロジェクト: owlscatcher/QR-code-scan
        private void StartStop_button_Click(object sender, EventArgs e)
        {
            if (!StartClickState)
            {
                // start camera stream
                videoSource           = new VideoCaptureDevice(videoDevice[Device_listBox.SelectedIndex].MonikerString);
                videoSource.NewFrame += new NewFrameEventHandler(stream);
                videoSource.Start();

                StartStop_button.Text = "Stop scan";
                StartClickState       = true;
            }
            else
            {
                if (videoSource != null)
                {
                    // stop camera stream
                    videoSource.SignalToStop();
                    videoSource.WaitForStop();

                    StartClickState         = false;
                    StartStop_button.Text   = "Start scan";
                    Stream_pictureBox.Image = null;
                    QrDecode_textBox.Text   = null;
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: KseniyaMikhailiuk/videochat
        private void Abort()
        {
            if (WebCam != null)
            {
                WebCam.SignalToStop();
                WebCam.WaitForStop();
                WebCam = null;
            }
            if (SendReceiveDisplayProcess.listeningSocket != null)
            {
                SendReceiveDisplayProcess.listeningSocket.Close();
                SendReceiveDisplayProcess.listeningSocket.Dispose();
            }
            if (SendReceiveDisplayProcess.client != null)
            {
                SendReceiveDisplayProcess.client.Close();
                SendReceiveDisplayProcess.client.Dispose();
            }


            if (SendReceiveDisplayProcess.output != null)
            {
                SendReceiveDisplayProcess.output.Stop();
                SendReceiveDisplayProcess.output.Dispose();
                SendReceiveDisplayProcess.output = null;
            }
            if (SendReceiveDisplayProcess.input != null)
            {
                SendReceiveDisplayProcess.input.Dispose();
                SendReceiveDisplayProcess.input = null;
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: iceslab/KamerkaWF
 private void CaptureButton_Click(object sender, EventArgs e)
 {
     if (videoSource != null)
     {
         if (videoSource.IsRunning)
         {
             videoSource.SignalToStop();
             videoSource.WaitForStop();
             CaptureBox.Invoke(
                 new Action(
                     delegate
             {
                 CaptureBox.Image = null;
                 CaptureBox.Invalidate();
             }));
             CaptureButton.Name = "Start";
         }
         else
         {
             videoSource.NewFrame += videoSource_NewFrame;
             videoSource.Start();
             CaptureButton.Name = "Stop";
         }
         SnapshotButton.Enabled = videoSource.IsRunning;
         RecordButton.Enabled   = videoSource.IsRunning;
     }
 }
コード例 #4
0
        private void OpenDeviceButton_Click(object sender, EventArgs e)
        {
            if (_device != null)
            {
                _device.Stop();
                _device.WaitForStop();
            }

            //OpenDeviceButton.Enabled = false;

            using (OpenDeviceForm openDeviceForm = new OpenDeviceForm(_frameSize))
            {
                if (openDeviceForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    if (openDeviceForm.SelectedDevice != null)
                    {
                        _device = openDeviceForm.SelectedDevice;

                        _device.NewFrame -= Device_NewFrame;
                        _device.NewFrame += Device_NewFrame;

                        _device.Start();
                    }
                }
            }
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: DimaFormaniuk/projectLab
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (FinalFrame != null)
     {
         FinalFrame.SignalToStop();
         FinalFrame.WaitForStop();
     }
 }
コード例 #6
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (FinalVideo != null)
     {
         FinalVideo.SignalToStop();
         FinalVideo.WaitForStop();
     }
 }
コード例 #7
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (newVideo.IsRunning)
     {
         newVideo.SignalToStop();
         newVideo.WaitForStop();
     }
 }
コード例 #8
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (Finalvideo.IsRunning)
     {
         Finalvideo.SignalToStop();
         Finalvideo.WaitForStop();
     }
 }
コード例 #9
0
ファイル: Main.cs プロジェクト: Sumedha1234/ObjectTracking
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (FinalFrame.IsRunning == true)
     {
         FinalFrame.SignalToStop();
         FinalFrame.WaitForStop();
         FinalFrame.Stop();
     }
 }
コード例 #10
0
 public override void StopLiveView()
 {
     lock (_lock)
     {
         _captureDevice.SignalToStop();
         _captureDevice.WaitForStop();
         _operationInProgress = false;
         _processLiveView     = false;
     }
 }
コード例 #11
0
        private void StopVideoCaptureDevice()
        {
            if (m_device == null)
            {
                return;
            }

            m_device.SignalToStop();
            m_device.WaitForStop();

            m_device.NewFrame -= NewFrameReceived;

            m_device = null;
        }
コード例 #12
0
ファイル: Form3_1.cs プロジェクト: DezRill/ArduinoProject
        private void button15_Click(object sender, EventArgs e)
        {
            control = true;
            Form1 frm = new Form1(l);

            frm.Show();
            this.Close();

            if (videoSource != null)
            {
                videoSource.SignalToStop();
                videoSource.WaitForStop();
            }
        }
コード例 #13
0
 private void CloseButton_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     if (device != null)
     {
         device.SignalToStop();
         device.WaitForStop();
     }
     if (device2 != null)
     {
         device2.SignalToStop();
         device2.WaitForStop();
     }
     Application.Current.Shutdown();
 }
コード例 #14
0
        private void StopCamera()
        {
            frame.SignalToStop();
            frame.NewFrame -= new NewFrameEventHandler(FrameEvent);
            frame.WaitForStop();
            while (frame.IsRunning)
            {
                frame.Stop();
            }

            //Ask if user wants to save camera image

            EnableCameraControls(false);
        }
コード例 #15
0
ファイル: Form1.cs プロジェクト: bendabin/RobotFootball
 private void Stop_button_Click(object sender, EventArgs e)
 {
     videoSource.SignalToStop();
     videoSource.WaitForStop();
     pictureBoxVideo.Image = null;
     pictureBoxMod.Image   = null;
 }
コード例 #16
0
 private void buttonDesconectar_Click(object sender, EventArgs e)
 {
     //DETENER LA RECEPCIÓN DE IMAGENES
     FuenteDeVideo.SignalToStop();
     FuenteDeVideo.WaitForStop();
     FuenteDeVideo.Stop();
 }
コード例 #17
0
 private void materialButtoncamera_Click(object sender, EventArgs e)
 {
     try
     {
         if (state == 1)
         {
             FinalVideo.SignalToStop();
             FinalVideo.WaitForStop();
             state = 0;
             materialButtoncamera.BackgroundImage = Properties.Resources.camera_1;
         }
         else
         {
             if (FinalVideo == null)
             {
                 FinalVideo = new VideoCaptureDevice(VideoCaptureDevices[0].MonikerString);
             }
             if (state == -1)
             {
                 FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
             }
             FinalVideo.Start();
             state = 1;
             materialButtoncamera.BackgroundImage = Properties.Resources.camera_settings_focus;
         }
     }
     catch (Exception ex)
     {
         Notify.show(ex.Message, 3);
     }
 }
コード例 #18
0
 private void CameraDropdown_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (Lock)
     {
         return;
     }
     if (cam != null)
     {
         cam.SignalToStop();
         cam.WaitForStop();
     }
     cam = new VideoCaptureDevice(filters[CameraDropdown.SelectedIndex].MonikerString);
     Prefs.SetCamera(filters[CameraDropdown.SelectedIndex]);
     cam.NewFrame += FrameTick;
     cam.Start();
 }
コード例 #19
0
        static void TestCameraStartStop()
        {
            int i           = 0;
            var collections = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            var _capture    = new VideoCaptureDevice(collections[i].MonikerString);

            _capture.VideoResolution = _capture.VideoCapabilities.FirstOrDefault(item => System.Math.Abs(item.FrameSize.Width - 320) < 0.1 &&
                                                                                 System.Math.Abs(item.FrameSize.Height - 240) < 0.1);
            _capture.NewFrame += _captures_NewFrame;

            int steps = 300 * 30 * 3;

            do
            {
                _capture.Start();
                Thread.Sleep(100);
                _capture.SignalToStop();
                _capture.WaitForStop();
                i++;
                Marshal.CleanupUnusedObjectsInCurrentContext();
                GC.WaitForFullGCComplete();
                GC.GetTotalMemory(true);
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
                string str = string.Format("Test nr {0}/{1}, mem = {2} Mbytes", i, steps,
                                           Process.GetCurrentProcess().PrivateMemorySize64 / 1024.0 / 1024.0);
                Console.WriteLine(str);
            } while (i < steps);
            Console.ReadKey();
        }
コード例 #20
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            try
            {
                if (_videoCaptureDevice != null)
                {
                    _videoCaptureDevice.Stop();
                    _videoCaptureDevice.WaitForStop();
                    _fileWriter.Close();

                    if (!_isPreviewMode)
                    {
                        if (_isAudioRecording)
                        {
                            _waveIn.StopRecording();
                            _waveIn.Dispose();
                            _waveIn = null;
                            _waveWriter.Close();
                            _waveWriter = null;
                        }
                        Mergefile(_audioFilePath, _videoFilePath);
                    }
                }
                System.Windows.Application.Current.Shutdown();
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex);
            }
        }
コード例 #21
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     videoSource.SignalToStop();
     videoSource.WaitForStop();
     writer.Close();
     ShowCurrentStatus("stop");
 }
コード例 #22
0
ファイル: Form1.cs プロジェクト: Edward125/CameraDevice
 private void button1_Click(object sender, EventArgs e)
 {
     FinalVideo.SignalToStop();
     FinalVideo.WaitForStop();
     picDevice.Image     = null;
     picDevice.BackColor = Color.Black;
 }
コード例 #23
0
 private void Window_Closing(object sender, CancelEventArgs e)
 {
     LocalWebCam.SignalToStop();
     LocalWebCam.WaitForStop();
     //Environment.Exit(Environment.ExitCode);
     //e.Cancel = true;
 }
コード例 #24
0
        public bool ToggleMode(IMode mode)
        {
            Mode newMode = (Mode)Modes.Keys.First(m => m.Text == mode.Text);

            dev.DesiredFrameRate = newMode.Capabilities.MaxFrameRate;
            dev.DesiredFrameSize = newMode.Capabilities.FrameSize;

            if (dev.IsRunning)
            {
                new Thread(() =>
                {
                    dev.SignalToStop();
                    dev.WaitForStop();
                    dev.Start();
                }).Start();
            }

            foreach (var m in Modes.Keys)
            {
                // notify that all modes are off, except the new one
                ModeStateChanged(m, m == newMode);
            }
            Settings["SelectedMode"] = mode.Text;
            return(true);
        }
コード例 #25
0
 /// <summary>
 /// stop capture of selected webcam
 /// </summary>
 public void stopWebcam()
 {
     ConsoleBuddy.WriteLineBlue("Enter in stopWebcam method");
     try
     {
         if (this.videoDeviceForCapture != null)
         {
             videoDeviceForCapture.SignalToStop();
             videoDeviceForCapture.WaitForStop();
             ConsoleBuddy.WriteLine(this.videoDeviceForCapture.FramesReceived.ToString() + " frames received after WaitForStop");
         }
         // close AVI writer if open
         if (this.writer != null)
         {
             this.writer.Close();
         }
         this.timer.Stop();
         ConsoleBuddy.WriteLineBlue("Exit stopWebcam method");
     }
     catch (ApplicationException e)
     {
         System.Console.WriteLine("ApplicationException in stopWebcam method:\n" + e.Message);
     }
     catch (SystemException sysEx)
     {
         this.ConsoleBuddy.WriteException(sysEx, "stopWebcam");
     }
 }
コード例 #26
0
        public static void SetDevice(string name)
        {
            var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            if (_videoDevice != null)
            {
                _videoDevice.NewFrame -= HandleNewFrame;
                _videoDevice.SignalToStop();
                _videoDevice.WaitForStop();
            }

            if (name + "" == "")
            {
                return;
            }

            foreach (FilterInfo device in videoDevices)
            {
                if (device.Name != name)
                {
                    continue;
                }
                _videoDevice           = new VideoCaptureDevice(device.MonikerString);
                _videoDevice.NewFrame += HandleNewFrame;
                _videoDevice.Start();
                break;
            }
        }
コード例 #27
0
        public CameraImageResponse GetXRAYImage(CameraImageCaptureRequest cameraImageCaptureRequest)
        {
            RTGMachine.busy       = true;
            videoDevices          = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            videoSource           = new VideoCaptureDevice(videoDevices[0].MonikerString);
            videoSource.NewFrame += video_NewCaptureFrame;

            RTGMachine.aTimer          = new System.Timers.Timer(10000);
            RTGMachine.aTimer.Elapsed += RTGMachine.OnTimedEvent;
            RTGMachine.aTimer.Enabled  = true;
            videoSource.Start();



            videoSource.WaitForStop();


            byte[] imageStreamByteArray = stream.ToArray();

            string imageBase64String = ConvertToBase64(imageStreamByteArray);

            CameraImageResponse cameraImageResponse = new CameraImageResponse();

            cameraImageResponse.Base64 = imageBase64String;

            return(cameraImageResponse);
        }
コード例 #28
0
 public void StopCam()                             //turn witch cam off
 {
     videoSource.NewFrame -= videoSource_NewFrame; //remove new Frame event handler
     videoSource.Stop();
     videoSource.SignalToStop();
     videoSource.WaitForStop();
 }
コード例 #29
0
 public void StopCamera(Camera camera)
 {
     _videoCaptureDevice.SignalToStop();
     _videoCaptureDevice.WaitForStop();
     _videoCaptureDevice.Stop();
     _videoCaptureDevice.NewFrame -= Video_NewFrame;
 }
コード例 #30
0
        /// <summary>
        /// monikerに対応するカメラから画像を1枚取得し、Bitmap型で返すメソッド
        /// string moniker:カメラのデバイスインスタンスパス
        /// </summary>
        /// <returns>取得した画像データ</returns>
        public Bitmap Shoot()
        {
            Photo = null;

            if (!WebApiApplication.filterInfoCollection.Cast <FilterInfo>().Any(filterInfo => (filterInfo.MonikerString == Moniker)))
            {
                throw new InvalidOperationException("該当するカメラが存在しません。");
            }


            var videoCaptureDevice = new VideoCaptureDevice(Moniker);

            videoCaptureDevice.NewFrame += new NewFrameEventHandler(PickFrame); // カメラが画像を取得したときに発生するイベント

            videoCaptureDevice.Start();

            try
            {
                if (!shotEvent.WaitOne(1000))
                {
                    throw new InvalidOperationException("画像が取得できませんでした。該当するカメラが存在しないか、接続が切断された可能性があります。");
                }
            }
            finally
            {
                videoCaptureDevice.SignalToStop();
                videoCaptureDevice.WaitForStop();
            }

            return(Photo);
        }