1 package org
.usfirst
.frc
.team3501
.robot
;
3 import com
.ni
.vision
.NIVision
;
4 import com
.ni
.vision
.NIVision
.Image
;
6 import edu
.wpi
.first
.wpilibj
.CameraServer
;
8 public class CameraFeeds
{
11 private int camIntake
;
12 private int camShooter
;
13 private int currentCam
;
16 private CameraServer server
;
18 public CameraFeeds() {
19 // get camera id's by giving camera name on roboRio web interface
20 camIntake
= NIVision
.IMAQdxOpenCamera(Constants
.CameraFeeds
.camNameIntake
,
21 NIVision
.IMAQdxCameraControlMode
.CameraControlModeController
);
22 camShooter
= NIVision
.IMAQdxOpenCamera(Constants
.CameraFeeds
.camNameIntake
,
23 NIVision
.IMAQdxCameraControlMode
.CameraControlModeController
);
25 // img that will contain camera img
26 frame
= NIVision
.imaqCreateImage(NIVision
.ImageType
.IMAGE_RGB
, 0);
28 // server we will give the image to
29 server
= CameraServer
.getInstance();
30 server
.setQuality(Constants
.CameraFeeds
.imgQuality
);
35 changeCam(camShooter
);
39 // change camera based on direction robot is moving in (whatever is front)
40 // (initial front is shooter)
41 if (currentCam
!= camIntake
&& Robot
.driveTrain
.isFlipped())
43 else if (currentCam
!= camShooter
) {
44 changeCam(camShooter
);
53 NIVision
.IMAQdxStopAcquisition(currentCam
);
57 * switch which camera your getting images from
62 public void changeCam(int newId
) {
63 NIVision
.IMAQdxStopAcquisition(currentCam
);
64 NIVision
.IMAQdxConfigureGrab(newId
);
65 NIVision
.IMAQdxStartAcquisition(newId
);
70 * Get img from current camera and give it to server
72 public void updateCam() {
73 NIVision
.IMAQdxGrab(currentCam
, frame
, 1);
74 server
.setImage(frame
);