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 @SuppressWarnings("deprecation")
15 public CameraFeeds() {
16 // Get camera ids by supplying camera name ex 'cam0', found on roborio web
18 intakeCam
= NIVision
.IMAQdxOpenCamera(Constants
.CameraFeeds
.camNameCenter
,
19 NIVision
.IMAQdxCameraControlMode
.CameraControlModeController
);
20 climberCam
= NIVision
.IMAQdxOpenCamera(Constants
.CameraFeeds
.camNameRight
,
21 NIVision
.IMAQdxCameraControlMode
.CameraControlModeController
);
23 // Img that will contain camera img
24 frame
= NIVision
.imaqCreateImage(NIVision
.ImageType
.IMAGE_RGB
, 0);
25 // Server that we'll give the img to
26 server
= CameraServer
.getInstance();
27 server
.setSize(Constants
.CameraFeeds
.imgQuality
);
36 if(/*add test for toggle*/)
39 if(/*add test for toggle*/)
40 changeCam(climberCam
);
46 * Stop aka close camera stream
49 NIVision
.IMAQdxStopAcquisition(curCam
);
53 * Change the camera to get imgs from to a different one
58 public void changeCam(int newId
) {
59 NIVision
.IMAQdxStopAcquisition(curCam
);
60 NIVision
.IMAQdxConfigureGrab(newId
);
61 NIVision
.IMAQdxStartAcquisition(newId
);
66 * Get the img from current camera and give it to the server
68 public void updateCam() {
69 NIVision
.IMAQdxGrab(curCam
, frame
, 1);
70 server
.setImage(frame
);