Como inicializar a webcam do AForge
Eu tento escrever uma pequena paz de código para capturar um quadro usando Aforge fiz uma referência para Aforge.dll e AForge.Video.DirectShow.dll O código está abaixo, mas estou fazendo algo errado. O aviso eu recebo "o nome videoDevices não existe no contexto atual. Eu acho que tem a ver sobre onde eu tento criar essa variável, mas eu não sei exatamente onde colocar esse código do botão para obtê-lo inicializado O erro é exibido no visual studio também como um redline sob o objeto "videoDevices"
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;
using AForge.Video.DirectShow;
namespace AforgeCam
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
if (videoDevices.Count == 0)
throw new ApplicationException();
foreach (FilterInfo device in videoDevices)
{
VideoCaptureDevice videoSource = new VideoCaptureDevice(device.MonikerString);
videoSource.DesiredFrameSize = new Size(320, 240);
videoSource.DesiredFrameRate = 15;
videoSourcePlayer1.VideoSource = videoSource;
videoSourcePlayer1.Start();
}
}
}
}