After messing around with cameras today, I was able to figure out how to use multiple cameras while only using the bandwidth of one. To do such, you simply switch between which feed you are sending back to the driver station with the touch of a button. See the code down below to see how to do this.
Variables needed:
Code:
int currSession;
int sessionfront;
int sessionback;
Image frame;
Init code:
Code:
frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
sessionfront = NIVision.IMAQdxOpenCamera("cam1", NIVision.IMAQdxCameraControlMode.CameraControlModeController);
sessionback = NIVision.IMAQdxOpenCamera("cam2", NIVision.IMAQdxCameraControlMode.CameraControlModeController);
currSession = sessionfront;
NIVision.IMAQdxConfigureGrab(currSession);
Switch between views:
Code:
if(/*button pressing code*/){
if(currSession == sessionfront){
NIVision.IMAQdxStopAcquisition(currSession);
currSession = sessionback;
NIVision.IMAQdxConfigureGrab(currSession);
} else if(currSession == sessionback){
NIVision.IMAQdxStopAcquisition(currSession);
currSession = sessionfront;
NIVision.IMAQdxConfigureGrab(currSession);
}
}
Sending the images to the DS:
Code:
NIVision.IMAQdxGrab(currSession, frame, 1);
CameraServer.getInstance().setImage(frame);
This code can easily be extended to include more than two cameras, if you wish. If anyone needs help implementing this, feel free to PM me/post below.