1 package org
.usfirst
.frc
.team3501
.robot
;
3 import com
.ni
.vision
.NIVision
;
4 import com
.ni
.vision
.NIVision
.Image
;
5 import edu
.wpi
.first
.wpilibj
.CameraServer
;
7 public class CameraFeeds
{
8 private final int intakeCam
;
9 private final int climberCam
;
12 private CameraServer server
;
14 public CameraFeeds() {
15 // Get camera ids by supplying camera name ex 'cam0', found on roborio web
17 intakeCam
= NIVision
.IMAQdxOpenCamera(Config
.CameraFeeds
.camNameCenter
,
18 NIVision
.IMAQdxCameraControlMode
.CameraControlModeController
);
19 climberCam
= NIVision
.IMAQdxOpenCamera(Config
.CameraFeeds
.camNameRight
,
20 NIVision
.IMAQdxCameraControlMode
.CameraControlModeController
);
22 // Img that will contain camera img
23 frame
= NIVision
.imaqCreateImage(NIVision
.ImageType
.IMAGE_RGB
, 0);
24 // Server that we'll give the img to
25 server
= CameraServer
.getInstance();
26 server
.setQuality(Config
.CameraFeeds
.imgQuality
);
35 if(/*add test for toggle*/)
38 if(/*add test for toggle*/)
39 changeCam(climberCam
);
45 * Stop aka close camera stream
48 NIVision
.IMAQdxStopAcquisition(curCam
);
52 * Change the camera to get imgs from to a different one
57 public void changeCam(int newId
) {
58 NIVision
.IMAQdxStopAcquisition(curCam
);
59 NIVision
.IMAQdxConfigureGrab(newId
);
60 NIVision
.IMAQdxStartAcquisition(newId
);
65 * Get the img from current camera and give it to the server
67 public void updateCam() {
68 NIVision
.IMAQdxGrab(curCam
, frame
, 1);
69 server
.setImage(frame
);