0

I need to process two USB webcams using VB.NET. I used AForge library for this. The problem is that just event handler of camera2 is triggered.

How can I activate both cameras?

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
rostamiani
  • 2,859
  • 7
  • 38
  • 74
  • Update: This problem occurs only when I connect both cameras to USB3 ports of my laptop. There is not any problems using USB2 – rostamiani Oct 09 '18 at 09:18
  • 1
    I'm not saying it will solve the problem, but you really should use [`Option Strict On`](https://stackoverflow.com/a/29985039/1115360). – Andrew Morton Oct 09 '18 at 09:21

1 Answers1

0

I know it is late to answer, but may be it will help someone, i was facing the same issue, in my case i was using the usb hub to connect multiple usb cameras , i fix this issue by putting usb camers in two different usb ports of system and it works. one more issue which i found during this is when i add 3 usb cameras the camera at index 0 is not working.