Aforge使用多个摄像头的视频卡 [英] Aforge working with video card with multiple cameras
问题描述
我可以让Aforge使用USB网络摄像头,但我有一个可以连接到多个摄像头的视频卡。如何让Aforge使用视频卡?
我的问题是我无法获得视频输入设备设置为正常的视频输入。
代码如下:
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;
}
我也试过:
finalVideo = new VideoCaptureDevice();
finalVideo.CrossbarVideoInput = VideoInput.Default;
也无效。
$ p
$
VideoCaptureDevice finalVideo = new VideoCaptureDevice(videoCaptureDevice [0] .MonikerString);
注册第一个设备[0]
也请注意这一行
finalVideo.NewFrame + = new NewFrameEventHandler(finalVideo_NewFrame);
你定义什么事件名称(finalvide_Newframe)应该触发,当有一个新的图像帧接收到专用摄像机。最简单的是注册两个不同的事件。所以每个摄像机[0]和[1]接收它自己的事件来显示它。
这里一些额外的代码提示可能对你有用相机,它只是一个想法,如果你有多个外部相机(使2组合框),但不想使用例如笔记本电脑内部凸轮。
VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach(VideoCaptureDevices中的FilterInfo VideoCaptureDevice)
{
comboBox1.Items.Add(VideoCaptureDevice.Name);
} //将所有设备放在组合框中;
您可以这样做
FinalVideo = new VideoCaptureDevice(VideoCaptureDevices [comboBox1.SelectedIndex] .MonikerString);
I can get Aforge to work with an USB web cam, but I have a video card that can connect to multiple cameras. How to 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.
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);
这篇关于Aforge使用多个摄像头的视频卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!