Start() публичный Метод

Start video source.
Starts video source and return execution to caller. Video source object creates background thread and notifies about new frames with the help of NewFrame event.
public Start ( ) : void
Результат void
Пример #1
3
        public bool Connect()
        {
            var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            if (videoDevices.Count == 0)
            {
                return false;
            }
            // create video source
            currentDevice = new VideoCaptureDevice(videoDevices[0].MonikerString);
            videoSourcePlayer1.VideoSource = currentDevice;
            var videoCapabilities = currentDevice.VideoCapabilities;
            //foreach (var video in videoCapabilities)
            //{
            //    LogHelper.Info("预览分辨率->" + video.FrameSize.Width + "*" + video.FrameSize.Height);
            //}
            if (videoCapabilities.Count() > 0)
                currentDevice.VideoResolution = currentDevice.VideoCapabilities.Last();

            var snapVabalities = currentDevice.SnapshotCapabilities;
            //foreach (var snap in snapVabalities)
            //{
            //    LogHelper.Info("抓拍分辨率->" + snap.FrameSize.Width + "*" + snap.FrameSize.Height);
            //}
            if (snapVabalities.Count() > 0)
                currentDevice.SnapshotResolution = currentDevice.SnapshotCapabilities.Last();

            currentDevice.Start();

            return true;
        }
Пример #2
1
        private void button1_Click(object sender, EventArgs e)
        {
            cam = new VideoCaptureDevice(webcams[comboBox1.SelectedIndex].MonikerString);
            cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);

            cam.Start();
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            vkl             = true;
            button5.Enabled = false;
            button4.Enabled = true;
            var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            height        = Settings.height;
            width         = Settings.width;
            player        = new VideoSourcePlayer();
            player.Top    = 30;
            player.Left   = 30;
            player.Width  = width;
            player.Height = height;
            player.Show();
            Controls.Add(player);
            button1.Top  = height + 30;
            button1.Left = width + 50;
            button2.Top  = height + 60;
            button2.Left = width + 50;
            button3.Top  = height + 90;
            button3.Left = width + 50;
            button4.Top  = height + 120;
            button4.Left = width + 50;
            button5.Top  = height + 160;
            button5.Left = width + 50;
            cam          = new AForge.Video.DirectShow.VideoCaptureDevice(videoDevices[0].MonikerString);
            cam.Start();
            player.VideoSource = cam;
            player.Start();
        }
Пример #4
0
        public void GetFrame()
        {
            // enumerate video devices
            var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            //foreach (FilterInfo item in videoDevices)
            //{

            //videoSource = new VideoCaptureDevice(item.MonikerString);
            videoSource = new VideoCaptureDevice(videoDevices[1].MonikerString);
            //videoSource.DesiredFrameSize = new Size(160, 120);

            // create video source
            //VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);

            // set NewFrame event handler
            videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
            // start the video source
            videoSource.Start();
            // ...
            System.Threading.Thread.Sleep(500);
            Trace.WriteLine("FramesReceived: " + videoSource.FramesReceived);
            // signal to stop
            videoSource.SignalToStop();
            // ...
            //}
        }
Пример #5
0
        public void Start()
        {
            FilterInfoCollection videoDevices;
            string camDescr;
            try
            {
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                if (videoDevices.Count == 0)
                {
                    throw new ApplicationException("no webcams");
                }
                else
                {
                    camName = videoDevices[Convert.ToInt32(devIndex)].MonikerString;
                    camDescr = videoDevices[Convert.ToInt32(devIndex)].Name;
                }
            }
            catch (ApplicationException)
            {
                throw new ApplicationException("failed web cams initialize");
            }

            videoSource = new VideoCaptureDevice(camName);
            videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
            videoSource.DesiredFrameSize = new Size(Convert.ToInt32(devWidth), Convert.ToInt32(devHeigth));//new Size(320, 240);//new Size(480, 360);//new Size(640, 480);//
            videoSource.DesiredFrameRate = 29;
            videoSource.Start();

            if (timerUploadImage == null)
            {
                timerUploadImage = new System.Timers.Timer(700);
                timerUploadImage.Elapsed += new ElapsedEventHandler(timerUploadImage_Tick);
                timerUploadImage.Start();
            }
        }
Пример #6
0
        public MainWindow()
        {
            InitializeComponent();

            ////////////////////Video Config - Start//////////////////////
            FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            string toPrint = "";
            foreach (FilterInfo vidDevice in videoDevices)
            {
                toPrint += vidDevice.MonikerString + "  \n  ";
            }
            MessageBox.Show("Found:\n\n" + toPrint);
            if (videoDevices.Count < 2)
            {
                MessageBox.Show("Not enough webcams detected, closing");
                Environment.Exit(0);
            }
            VideoCaptureDevice leftSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
            VideoCaptureDevice rightSource = new VideoCaptureDevice(videoDevices[1].MonikerString);

            leftSource.Start();
            rightSource.Start();

            leftPlayer.VideoSource = leftSource;
            rightPlayer.VideoSource = rightSource;

            leftHost.Child = leftPlayer;
            rightHost.Child = rightPlayer;

            leftPlayer.Start();
            rightPlayer.Start();
        }
        private void button_iniciar_Click(object sender, EventArgs e)
        {
            if (button_iniciar.Text.Equals("Iniciar"))
            {
                if (existem_dispositivos)
                {
                    fonte_video = new VideoCaptureDevice(dispositivos_video[comboBox_dispositivo.SelectedIndex].MonikerString);
                    fonte_video.NewFrame += new NewFrameEventHandler(VideoNovoFrame);
                    fonte_video.Start();
                    //statusStrip_barra.Text = "Executando dispositivo";
                    button_iniciar.Text = "Parar";
                    comboBox_dispositivo.Enabled = false;
                    //label_nome.Text = dispositivos_video[comboBox_camera.SelectedIndex].ToString();

                }
                else
                {
                    //statusStrip_barra.Text = "Error: Não encontrado dispositivo";
                }

            }
            else
            {
                if (fonte_video != null)// || fonte_video.IsRunning)
                {
                    TerminarFonteVideo();
                    //statusStrip_barra.Text = "Dispositivo Terminado";
                    //button_iniciar.Text = "Iniciar";
                    comboBox_dispositivo.Enabled = true;
                }
            }
        }
Пример #8
0
 private void btnComeçar_Click(object sender, RoutedEventArgs e)
 {
     //Iniciar a camera e mostrar no picture Box[form control] por meio do evento
     cam = new VideoCaptureDevice(webcam[cmbDevices.SelectedIndex].MonikerString);
     cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
     cam.Start();
 }
Пример #9
0
 public static void Cameraint(int i)
 {
     videoSource = new VideoCaptureDevice(videoDevices[i].MonikerString);
      videoSource.DesiredFrameSize = new Size(2048, 1536);
      videoSource.DesiredFrameRate = 1;
      videoSource.Start();
 }
        public void StartVideo()
        {
            if (filterInfoCollection != null)
            {
                videoCaptureDevice = new VideoCaptureDevice(filterInfoCollection[1].MonikerString);
                try
                {
                    if (videoCaptureDevice.VideoCapabilities.Length > 0)
                    {
                        string highestSolution = "0;0";

                        for (int i = 0; i < videoCaptureDevice.VideoCapabilities.Length; i++)
                        {
                            highestSolution = videoCaptureDevice.VideoCapabilities[i].FrameSize.Width.ToString() +';'
                            +i.ToString();
                        }

                        videoCaptureDevice.VideoResolution =
                            videoCaptureDevice.VideoCapabilities[Convert.ToInt32(highestSolution.Split(';')[1])];

                    }

                }
                catch (Exception e)
                {

                }

                videoCaptureDevice.NewFrame += newFrameEventHandler;

                videoCaptureDevice.Start();
            }
        }
Пример #11
0
 private void button2_Click(object sender, EventArgs e)
 {
     FinalVideo2 = new VideoCaptureDevice(VideoCaptureDevices[comboBox1.SelectedIndex].MonikerString);
     FinalVideo2.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame2);
     FinalVideo2.Start();
     //   FinalVideo.Stop();
 }
Пример #12
0
 private void btnIniciar_Click(object sender, EventArgs e)
 {
     if (btnIniciar.Text == "Start")
     {
         if (ExistenDispositive)
         {
             FuenteVideo = new VideoCaptureDevice(DispositiveVideo[cboDispositive.SelectedIndex].MonikerString);
             FuenteVideo.NewFrame += new NewFrameEventHandler(video_NuevoFrame);
             FuenteVideo.Start();
             Estado.Text = "Connection Complete";
             btnIniciar.Text = "Stop";
             cboDispositive.Enabled = false;
             groupBox1.Text = DispositiveVideo[cboDispositive.SelectedIndex].Name.ToString();
         }
         else
             Estado.Text = "Error: No matching device.";
     }
     else {
         if (FuenteVideo.IsRunning) {
             btnIniciar.Text = "Start";
             TerminarFuenteDeVideo();
             Estado.Text = "Dispositiveo detenio";
             cboDispositive.Enabled = true;
         }
     }
 }
Пример #13
0
        public void button1_Click(object sender, EventArgs e)
        {
            _controller.Connect(new SerialPort((string)comboBox2.SelectedItem, 57600));

            videoSource = new VideoCaptureDevice(videoDevices[comboBox1.SelectedIndex].MonikerString);
            videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
            videoSource.Start();
        }
Пример #14
0
        public WebCam(string VideoDeviceMoniker)
        {
            thisvideoSource = new VideoCaptureDevice(VideoDeviceMoniker);

            thisvideoSource.NewFrame += new NewFrameEventHandler(Cam_NewFrame);
            thisvideoSource.DesiredFrameRate = 60;
            thisvideoSource.Start();
        }
Пример #15
0
        public Logic()
        {
            videodevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            videoSource = new VideoCaptureDevice(videodevices[0].MonikerString);

            videoSource.NewFrame += videoSource_NewFrame;
            videoSource.Start();
        }
Пример #16
0
 private void InitializeCapture()
 {
     FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
     videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
     videoSource.NewFrame += new NewFrameEventHandler(NewFrameHandler);
     videoSource.VideoResolution = videoSource.VideoCapabilities[4];
     defaultRect = new System.Drawing.Rectangle(0, 0, videoSource.VideoResolution.FrameSize.Width, videoSource.VideoResolution.FrameSize.Height);
     videoSource.Start();
 }
Пример #17
0
 private void button3_Click(object sender, EventArgs e)
 {
     videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); // список устройств
     videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);  // подключения устройства
     videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame);  // создание источника видеосигнала 
     pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
     videoSource.Start();
   
 }
Пример #18
0
 public void Start()
 {
     if (deviceExists)
     {
         videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
         videoSource.NewFrame += videoSource_NewFrame;
         videoSource.Start();
     }
 }
Пример #19
0
        private void btnCStart_Click(object sender, EventArgs e)
        {
            usbCams = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            cam = new VideoCaptureDevice(usbCams[0].MonikerString);

            cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);

            cam.Start();
        }
Пример #20
0
        public MainForm()
        {
            InitializeComponent();
            timerLapso.Stop();
            timerCaptura.Stop();
            buttonEmpezar.Focus();

            //TestSet testSet = TestSetDao.GetTestSet(defaultTestSet);

            VideoSources = new AForge.Video.DirectShow.FilterInfoCollection(AForge.Video.DirectShow.FilterCategory.VideoInputDevice);
            if (VideoSources != null)
            {
                foreach (Screen screens1 in Screen.AllScreens)
                {
                    comboBoxPantallas.Items.Add(screens1.DeviceName);
                }

                screens2 = Screen.AllScreens;

                comboBoxPantallas.SelectedIndex = 0;

                foreach (FilterInfo VideoSource in VideoSources)
                {
                    comboBoxWebCam.Items.Add(VideoSource.Name);
                }

                VideoSource           = new AForge.Video.DirectShow.VideoCaptureDevice(VideoSources[0].MonikerString);
                VideoSource.NewFrame += new NewFrameEventHandler(FinalFrame_NewFrame);
                VideoSource.Start();

                if (comboBoxWebCam.Items.Count > 0)
                {
                    comboBoxWebCam.SelectedIndex = 0;
                }
            }

            buttonTerminar.Enabled = false;

            try {
                Conexion.Open();

                SqlCommand    cmd = new SqlCommand("select max(SECCION) AS SECCION from [NEUROSKY_IMAGENES]", Conexion);
                SqlDataReader dr  = cmd.ExecuteReader();

                if (dr.Read())
                {
                    int.TryParse(Convert.ToString(dr["SECCION"]), out this.Seccion);
                    Seccion++;
                }
                Conexion.Close();
            } catch (Exception e) {
                Console.WriteLine("Fallo la conexion a la base");
                Console.WriteLine(e.Message);
            }
        }
Пример #21
0
 private void initVideo()
 {
     // enumerate video devices
     FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
     // create video source
     VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
     // set NewFrame event handler
     videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
     // start the video source
     videoSource.Start();
 }
Пример #22
0
 public MotionCCTV()
 {
     
     InitializeComponent();
     isResolutionSet = false;
     webcam=new FilterInfoCollection(FilterCategory.VideoInputDevice);
     cam = new VideoCaptureDevice(webcam[0].MonikerString);
     md = new MotionDetector(new TwoFramesDifferenceDetector(), new MotionAreaHighlighting()); // creates the motion detector
     cam.NewFrame += new NewFrameEventHandler(cam_NewFrame); // defines which method to call when a new frame arrives
     cam.Start(); // starts the videoCapture
     Display.Paint += Display_Paint;
 }
Пример #23
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (_webcams.Count == 0)
            {
                MessageBox.Show("No Webcam installed!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            _camera = new VideoCaptureDevice(_webcams[0].MonikerString);
            _camera.NewFrame += _camera_NewFrame;
            _camera.Start();
        }
Пример #24
0
        private void FrmAorgeCamera_Load(object sender, EventArgs e)
        {
            if (camera.Devices.Count <= 0)
                return;

            var device = camera.Devices[0];
            videoDevice = new VideoCaptureDevice(device.MonikerString);
            var videoCapabilities = videoDevice.VideoCapabilities;
            //videoDevice.VideoResolution = videoCapabilities[10];
            videoDevice.NewFrame += videoDevice_NewFrame;
            videoDevice.Start();
        }
Пример #25
0
 private void Form1_Load(object sender, EventArgs e)
 {
     webcam = new FilterInfoCollection(FilterCategory.VideoInputDevice);
     foreach (FilterInfo VideoCaptureDevice in webcam)
     {
         comboBox1.Items.Add(VideoCaptureDevice.Name);
     }
     comboBox1.SelectedIndex = 1;
     cam = new VideoCaptureDevice(webcam[comboBox1.SelectedIndex].MonikerString);
     cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
     cam.Start();
 }
Пример #26
0
 private void comboBoxWebCam_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (VideoSources != null)
     {
         if (VideoSource.IsRunning)
         {
             VideoSource.Stop();
         }
         VideoSource           = new AForge.Video.DirectShow.VideoCaptureDevice(VideoSources[comboBoxWebCam.SelectedIndex].MonikerString);
         VideoSource.NewFrame += new NewFrameEventHandler(FinalFrame_NewFrame);
         VideoSource.Start();
     }
 }
Пример #27
0
 private void btnStartWebcam_Click(object sender, EventArgs e)
 {
     videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
     videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
     videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
     CloseVideoSource();
     videoSource.DesiredFrameSize = new Size(320, 240);
     //videoSource.DesiredFrameRate = 7;
     Thread.Sleep(2000);
     videoSource.Start();
     timerFrameRate.Enabled = true;
     btnStartWebcam.Enabled = false;
 }
Пример #28
0
        public snapShotSender(VideoCaptureDevice VCD)
        {
            videoDevice = VCD;
            VSP = new VideoSourcePlayer();
            videoCapabilities = videoDevice.VideoCapabilities;
            snapshotCapabilitites = videoDevice.SnapshotCapabilities;

            videoDevice.VideoResolution = videoCapabilities[0];
            videoDevice.ProvideSnapshots = true;
            videoDevice.SnapshotResolution = snapshotCapabilitites[_quality];
            videoDevice.SnapshotFrame += videoDevice_SnapshotFrame;
            VSP.VideoSource = videoDevice; //Idk why this has to happen to get snapshots, but it does...
            videoDevice.Start();
        }
Пример #29
0
 public static void HandleGetWebcam(GetWebcam command, Client client)
 {
     Client = client;
     NeedsCapture = true;
     Webcam = command.Webcam;
     if (!WebcamStarted)
     {
         var videoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
         FinalVideo = new VideoCaptureDevice(videoCaptureDevices[command.Webcam].MonikerString);
         FinalVideo.NewFrame += FinalVideo_NewFrame;
         FinalVideo.Start();
         WebcamStarted = true;
     }
 }
Пример #30
0
 private void btnStart_Click(object sender, EventArgs e)
 {
     try
     {
         if (_finalFrame.IsRunning) _finalFrame.Stop();
         _finalFrame = new VideoCaptureDevice(_captureDevice[cmbDeviceName.SelectedIndex].MonikerString);
         _finalFrame.NewFrame += FinalFrame_NewFrame;
         _finalFrame.Start();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #31
0
 private void frmFoto_Load(object sender, EventArgs e)
 {
     if (existenDispositivos)
     {
 	    fuenteDeVideo = new VideoCaptureDevice(dispositivosDeVideo[0].MonikerString);
 	    fuenteDeVideo.NewFrame += new NewFrameEventHandler(MostrarImagen);
 	    fuenteDeVideo.Start();
 	}
 	else
 	{
 	    MessageBox.Show("No se encuentra ningún dispositivo de vídeo en el sistema", "Información", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         this.Close();
      }
 }
Пример #32
0
 public bool startVideoSource(int index)
 {
     if (deviceExist)
     {
         videoSource = new VideoCaptureDevice(videoDevices[index].MonikerString);
         videoSource.NewFrame += new NewFrameEventHandler(videoFrameHandler);
         CloseVideoSource();
         videoSource.Start();
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #33
0
        public void StartCapturing(object logic)
        {
            _logic = (Logic)logic;
            int fps = 25;

            writerThread      = new Thread(ImageWriter);
            writerThread.Name = "writerThread";
            writerThread.Start();

            var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            _captureDevice = new VideoCaptureDevice(videoDevices[0].MonikerString);
            _captureDevice.DesiredFrameSize = new Size(704, 576);
            _captureDevice.DesiredFrameRate = fps;
            _captureDevice.NewFrame        += new AForge.Video.NewFrameEventHandler(camera_NewFrame);
            _captureDevice.Start();
            globFrameCount   = 0;
            globCaptureStart = DateTime.Now;
            //now capturing
        }
Пример #34
0
 private void AtivarFoto_CheckedChanged(object sender, EventArgs e)
 {
     if (AtivarFoto.Checked)
     {
         FilterInfoCollection videosource = new FilterInfoCollection(FilterCategory.VideoInputDevice);
         if (videosource != null)
         {
             videoSource = new AForge.Video.DirectShow.VideoCaptureDevice(videosource[0].MonikerString);;
             videoSource.VideoResolution = videoSource.VideoCapabilities[1];
             videoSource.NewFrame       += (s, a) => Foto.Image = (Bitmap)a.Frame.Clone();
             videoSource.Start();
         }
     }
     else
     {
         if (videoSource.IsRunning)
         {
             videoSource.Stop();
         }
     }
 }
Пример #35
-1
 private void button1_Click(object sender, EventArgs e)
 {
     videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
         videoSource.NewFrame += videoSource_NewFrame;
         videoSource.Start();
         while (newImage == null){}
         videoSource.Stop();
         newImage = null;
 }