View Single Post
  #8   Spotlight this post!  
Unread 04-02-2015, 06:57
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Switch between two cameras?

The default LV code has a loop that will start running its empty vision processing code when enabled on the robotMain front panel or when the global is set to true.

Anyway. The WPILib forwarding code wasn't really prepared for this, so it will take a modification or two.

The Vision Processing VI calls a subVI whose icon has IP & Dash on it. The actual name of the VI is Background loop, and it does several things for different cameras and assumes that the camera address doesn't change.

For USB cameras, it calls a VI labeled Send 2 PC that does the read/compress/send to bridge the USB camera over ethernet. The camera refnum used in that loop is the one that we want to switch back and forth. It is the nested loop that is reading the camera, flattening to a string and calling the Send Image String VI. The inner loop will normally continue as long as the network connection is valid.

The modification would be to Open both cameras and store their refnums in a global variable. Then inside of Send Image to PC, when the camera switches, you'd want to modify the refund and exit the inner loop. The outer loop will stop and start the new camera and reuse the networking connection.

These aren't hard edits, but they need to be done right or they will be hard to debug. If someone makes these edits, perhaps they can share their results with the community?

Edit: It looks like someone has done this in a peer thread. I haven't tested it.

Greg McKaskle

Last edited by Greg McKaskle : 04-02-2015 at 06:59. Reason: Update
Reply With Quote