AForge - Working with video card with multiple cameras
Asked Answered
J

2

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.

Jolin answered 8/11, 2012 at 20:51 Comment(0)
O
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);
Outlandish answered 28/11, 2012 at 23:3 Comment(2)
Sorry to say this would not work because the videoCaptureDevice is null. It did not see any video input.Jolin
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 aforge.googlecode.com/svn-history/r1680/trunk/Sources/…Outlandish
O
0

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

Outlandish answered 13/2, 2015 at 12:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.