Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8716185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:01:12+00:00 2026-06-13T06:01:12+00:00

I try to write a small peace of code to capture a frame using

  • 0

I try to write a small peace of code to capture a frame using Aforge
I made a reference to Aforge.dll and AForge.Video.DirectShow.dll
The code is below, but i am doing something wrong.
The Warning i get “the name videoDevices does not exist in the current context.
I think it has to do about where i try to create that variable but i’m not exactly sure as where to place that code of the button to get it initialized.
The error is displayed in visual studio also as a redline under the object “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();
        }

    }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:01:13+00:00Added an answer on June 13, 2026 at 6:01 am

    As requested the solution is below , the code works, i will raise a new question for another question i have about it. the code requires a dropdown box, 2 buttons and a picturebox

    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using AforgeCam;
    using AForge.Video;
    using AForge.Video.DirectShow;
    
    namespace AforgeCam
    {
    public partial class Form1 : Form
    {
    private FilterInfoCollection VideoCaptureDevices;
    private VideoCaptureDevice FinalVideo;
    
    public Form1() // init
    {
        InitializeComponent();
        {
            VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            foreach (FilterInfo VideoCaptureDevice in VideoCaptureDevices)
            {
                comboBox1.Items.Add(VideoCaptureDevice.Name);
            }
            comboBox1.SelectedIndex = 0;
        }
    }
    
    private void button1_Click(object sender, EventArgs e)
    {
        FinalVideo = new VideoCaptureDevice(VideoCaptureDevices[comboBox1.SelectedIndex].MonikerString);
        FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
        FinalVideo.Start();
    }
    
    void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs)
    {
        Bitmap video = (Bitmap)eventArgs.Frame.Clone();
        pictureBox1.Image = video;
    
    }
    
    private void button2_Click(object sender, EventArgs e)
    {
        FinalVideo.Stop();
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some thing ago, I write small script using Text::DeDupe to remove duplicates of blog
I've been trying to write a small library using Thor to help assist me
I am using the PHPExcel framework to try to write out a very large
This is the code that I want to try to write: #include <stdio.h> #include
I have small problem. I try to write a function to extract something in
Every time I try to write an image using imagejpeg() , I get the
I try to write a small application in go that takes 'x' numbers of
Now I try to write a small method to search in j2me, it works
I'm using OOP to write small games with different types of characters (e.g. platformers,
try to write a composite component that allows mutltiple text inputs. I read that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.