我需要使用 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