View Single Post
  #5   Spotlight this post!  
Unread 31-01-2016, 19:53
jojoguy10's Avatar
jojoguy10 jojoguy10 is offline
Programming/Controls Mentor
AKA: Joe Kelly
FRC #0997 (Spartan Robotics) and FRC #2990 (Hotwire Robotics)
Team Role: Mentor
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Stayton, OR
Posts: 283
jojoguy10 is a glorious beacon of lightjojoguy10 is a glorious beacon of lightjojoguy10 is a glorious beacon of lightjojoguy10 is a glorious beacon of lightjojoguy10 is a glorious beacon of light
Re: Switching between two webcams on the dashboard

Hey Teku14,

We successfully (after 5 hours!) managed to switch webcams. I will post the relevant VI snapshots and try to explain them the best I can. Here is a link to the code we tried and some annotated screenshots.
https://drive.google.com/folderview?...&usp=sha ring

Vision Processing:
We created two cameras (notice the different RefNum names ) and wired them into our new Background Loop VI.

CameraBackground Loop:
We had to create a second RefNum input for the second webcam and run two (2) Send2PC loops (one for each camera).

Send2PC:
It looks like you did the Send2PC perfectly. Just create controls for the port and the image name, and set them as inputs for the VI.

DASHBOARD:
DashboardMain:
We had to do a bit of trial and error to get this to work correctly. We have a bit of code (highlighted in the orange box) that would "refresh" the feed and the port. Without that code, we would flip the camera switcher, but the image wouldn't update with the new camera unless we switch from Camera HW to Camera SW (or vice versa). So, this little block of code automatically switches from HW to SW (or vice versa) if the port changes.

CameraRead_MJPG:
This was a tricky VI because it was a clone and you can't edit a clone. The trick I found to edit a VI is:
  • In the DashboardMain VI, do a CTRL+F (find)
  • Next, under "Select Object", click the "Add" button and go to: Objects in vi.lib and if you scroll all the way down, you will see the Camera VIs
  • Find the Dashbd MJPG VI and left-click on it
  • Next, in the "search Scope", choose the "<All VIs in Application Instance>" and make sure the "Hierarchy Window" checkbox is checked
  • Flick Find
  • Double-click on "VI Hierarchy"
  • You should be able to click and drag the VI (Dashbg MJPG) into the Dashboard Main VI so you can edit it
Now that you have that VI, you can open it up and continue on. Yay!

Inside that VI, there is a "Get On PC" VI inside the "1, 2" case in the middle case-structure. We had to edit that too :-)

Get on PC:
Since this VI is also a clone, do the same steps as above with the MJPG VI, (but, obviously, look for the Get On PC instead )

Moving on...

All we had to add was a control for the camera port and make it an input for the VI.


That's what we did. Let me know if you have any further questions at all.

Thanks again Greg for getting us on the right foot
__________________


Reply With Quote