View Single Post
  #12   Spotlight this post!  
Unread 03-02-2017, 10:25
Beachbotics Beachbotics is offline
Registered User
FRC #1876
 
Join Date: Dec 2014
Location: Hilton Head, SC
Posts: 5
Beachbotics is an unknown quantity at this point
Re: 2 Cameras Setup (Lifecam HD 3000)

To reduce bandwidth, and if only one camera at a time is needed, the following approach seems to work without errors:

1) Create 2 Usbcamera using new (not startAutomaticCapture)
2) Create a single sink and source
3) Use cvSink.setSource to change cameras as needed.

When I look at the Driver Station variables, it looks like only a single stream is created, and only the Current View shows as Camera option

Abbreviated code:

UsbCamera cam0 = new UsbCamera ("USB Camera 0", 0);
cam0.setResolution(320,240);
cam0.setFPS(20);
UsbCamera cam1 = new UsbCamera ("USB Camera 1", 1);
cam1.setResolution(320,240);
cam1.setFPS(20);
CvSink cvSink = CameraServer.getInstance().getVideo(cam0);
CvSource cvSource = CameraServer.getInstance().putVideo("Current View", 320, 240);
while(!Thread.interrupted() && !cameraKillf)
{
//Grab image
cvSink.grabFrame(source);

//If cam switch button pressed, switch cams
//choose either
// cvSink.setSource(cam1);
// cvSink.setSource(cam0);

//Display result to screen
cvSource.putFrame(output);
}
Reply With Quote