本文介绍了AForge-与多个摄像机一起使用视频卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我可以让AForge使用USB网络摄像头,但是我有一个视频卡可以连接到多个摄像机。如何让AForge与视频卡配合使用? 我的问题是我无法将 VideoInputDevice 插入设置为有效的视频输入。 代码如下: void init(){ FilterInfoCollection videoCaptureDevice = 新FilterInfoCollection(FilterCategory.VideoInputDevice); VideoCaptureDevice finalVideo = 新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; ,它也不起作用。 解决方案在您的代码中 VideoCaptureDevice finalVideo =新的VideoCaptureDevice(videoCaptureDevice [0] .MonikerString); 注册第一个设备[0] i假设如果您将[1]放到那里,则会得到第二个设备。 还请注意此行 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 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. 解决方案 in your codeVideoCaptureDevice 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-与多个摄像机一起使用视频卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-23 02:23