Comment initialiser AForge webcam

J'essaie d'écrire un petit bout de code pour capturer une image à l'aide Aforge
J'ai fait une référence à Aforge.dll et AForge.Video.DirectShow.dll
Le code est ci-dessous, mais je suis en train de faire quelque chose de mal.
L'Avertissement-je obtenir "le nom videoDevices n'existe pas dans le contexte actuel.
Je pense qu'il doit faire à ce sujet, où j'essaie de créer cette variable, mais je ne suis pas sûr de savoir exactement où placer ce code du bouton pour obtenir initialisé.
L'erreur est affichée dans visual studio aussi comme une ligne rouge sous l'objet "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();
        }

    }
    }
}

OriginalL'auteur user613326 | 2012-10-16