2

I can get AForge to work with an USB web cam, but I have a video card that can connect to multiple cameras. How do I get AForge to work with the video card?

My issue is I could not get the VideoInputDevice to set to a working video input.

The code is like this:

void init(){
    FilterInfoCollection videoCaptureDevice =
        new FilterInfoCollection(FilterCategory.VideoInputDevice);

    VideoCaptureDevice finalVideo =
        new VideoCaptureDevice(videoCaptureDevice[0].MonikerString);

    finalVideo.NewFrame += new NewFrameEventHandler(finalVideo_NewFrame);

    finalVideo.Start();
}

public void finalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
    Bitmap temp = (Bitmap)eventArgs.Frame.Clone();
    pictureBox1.Image = temp;

}

I also tried:

finalVideo = new VideoCaptureDevice();
finalVideo.CrossbarVideoInput = VideoInput.Default;

and it did not work either.

Any help is highly appreciated.

Tony Zenus
  • 33
  • 2
  • 6

2 Answers2

1

in your code

VideoCaptureDevice finalVideo = new VideoCaptureDevice(videoCaptureDevice[0].MonikerString);

registers the first device [0]
i asume if you would put in [1] there you get the second device.

also note this line

  finalVideo.NewFrame += new NewFrameEventHandler(finalVideo_NewFrame);

there you define what event name (finalvide_Newframe) should trigger when there is a new image frame received for that specific camera. Most simple would be to register two different events. So each camera [0] and [1] receives its own event to display it.

here some additional code hints that might be helpfull for you its what i use to select a camera, its just an idea for if you have multiple external camera's (make 2 combo boxes) but dont want to use for example a laptops internal cam.

VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            foreach (FilterInfo VideoCaptureDevice in VideoCaptureDevices)
            {
                comboBox1.Items.Add(VideoCaptureDevice.Name);
            } // to get all your devices inside a combo box;

with that you could do

 FinalVideo = new VideoCaptureDevice(VideoCaptureDevices[comboBox1.SelectedIndex].MonikerString);
user613326
  • 2,140
  • 9
  • 34
  • 63
  • Sorry to say this would not work because the videoCaptureDevice is null. It did not see any video input. – Tony Zenus Nov 29 '12 at 06:54
  • hm thats odd you also wrote that you can get it to work with an usb video camera. so it is the capture card that gives you problems. Did you took a look inside his code, its full of comments that might be usefully to your specific environment. take a look here http://aforge.googlecode.com/svn-history/r1680/trunk/Sources/Video.DirectShow/VideoCaptureDevice.cs – user613326 Nov 29 '12 at 10:44
0

look in the aforge examples when you download the whole package, there is a demo snapshotmaker, that works with multiple camera's.

user613326
  • 2,140
  • 9
  • 34
  • 63