我需要使用 VB.NET 处理两个USB网络摄像头。我为此使用了AForge库。问题是只触发了 camera2 的事件处理程序。
如何激活两个摄像头?
Dim camera1
Dim camera2
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim Cameras = New FilterInfoCollection(FilterCategory.VideoInputDevice)
Dim camera1 = New VideoCaptureDevice(Cameras(0).MonikerString)
Dim camera2 = New VideoCaptureDevice(Cameras(1).MonikerString)
AddHandler camera1.NewFrame, AddressOf NewFrameHandler1
AddHandler camera2.NewFrame, AddressOf NewFrameHandler2
camera1.Start()
camera2.Start()
End Sub
Private Sub NewFrameHandler1(sender As Object, eventArgs As NewFrameEventArgs)
Console.WriteLine("Camera 1 captured")
End Sub
Private Sub NewFrameHandler2(sender As Object, eventArgs As NewFrameEventArgs)
Console.WriteLine("Camera 2 captured")
End Sub
我知道现在回答已经很晚了,但也许它会帮助某人, 我面临着同样的问题,就我而言,我正在使用USB集线器连接多个USB相机,我通过将USB凸轮放在系统的两个不同的USB端口中来解决此问题,并且可以正常工作。 在此期间我发现的另一个问题是,当我添加 3 个 USB 相机时,索引为 0 的相机无法正常工作。