Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using AForge.Video;
- using AForge.Video.DirectShow;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- //AGREGAR REFERENCIAS
- //AGREGAR CONTROLES
- //DISEÑAR FORMULARIO
- // VideoSourcePlayer1 es el control donde se mostrará
- //la imagen de la webcam
- public Form1()
- {
- InitializeComponent();
- }
- //AGREGAR USING
- //VARIABLE PARA LISTA DE DISPOSITIVOS
- private FilterInfoCollection Dispositivos;
- //VARIABLE PARA FUENTE DE VIDEO
- private VideoCaptureDevice FuenteDeVideo;
- private void Form1_Load(object sender, EventArgs e)
- {
- //LISTAR DISPOSITIVOS DE ENTRADA DE VIDEO
- Dispositivos = new FilterInfoCollection(FilterCategory.VideoInputDevice);
- //CARGAR TODOS LOS DISPOSITIVOS AL COMBO
- foreach (FilterInfo x in Dispositivos)
- {
- comboBox1.Items.Add(x.Name);
- }
- comboBox1.SelectedIndex = 0;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- //ESTABLECER EL DISPOSITIVO SELECCIONADO COMO FUENTE DE VIDEO
- FuenteDeVideo = new VideoCaptureDevice(Dispositivos[comboBox1.SelectedIndex].MonikerString);
- //INICIALIZAR EL CONTROL
- videoSourcePlayer1.VideoSource = FuenteDeVideo;
- //INICIAR RECEPCION DE IMAGENES
- videoSourcePlayer1.Start();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- //DETENER RECEPCION DE IMAGENES
- videoSourcePlayer1.SignalToStop();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment