Attempt to toggle cameras
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / CameraFeeds.java
CommitLineData
e63d823c
ME
1package org.usfirst.frc.team3501.robot;
2
3import com.ni.vision.NIVision;
4import com.ni.vision.NIVision.Image;
f31051bd
RH
5
6import edu.wpi.cscore.AxisCamera;
7import edu.wpi.cscore.UsbCamera;
e63d823c
ME
8import edu.wpi.first.wpilibj.CameraServer;
9
10public class CameraFeeds {
cdcbf5c6
RH
11 // private final int intakeCam;
12 // private final int climberCam;
13 private Image frame;
18f2b59b 14 private boolean curCam = true;
e63d823c 15 private CameraServer server;
cdcbf5c6
RH
16 private static UsbCamera intakeCam;
17 private static AxisCamera climberCam;
e63d823c 18
c6008874 19 @SuppressWarnings("deprecation")
cdcbf5c6 20 public CameraFeeds(/* Joystick Button */) {
e63d823c
ME
21 // Get camera ids by supplying camera name ex 'cam0', found on roborio web
22 // interface
cdcbf5c6
RH
23 /*
24 * intakeCam =
25 * NIVision.IMAQdxOpenCamera(Constants.CameraFeeds.camNameCenter,
26 * NIVision.IMAQdxCameraControlMode.CameraControlModeController); climberCam
27 * = NIVision.IMAQdxOpenCamera(Constants.CameraFeeds.camNameRight,
28 * NIVision.IMAQdxCameraControlMode.CameraControlModeController); curCam =
29 * intakeCam; // Img that will contain camera img frame =
30 * NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0); // Server that
31 * we'll give the img to server = CameraServer.getInstance();
32 * server.setSize(Constants.CameraFeeds.imgQuality);
33 */
34 intakeCam = CameraServer.getInstance().startAutomaticCapture();
35 CameraServer.getInstance().startAutomaticCapture();
e63d823c 36 server = CameraServer.getInstance();
cdcbf5c6 37 climberCam = server.addAxisCamera("axisCamera", "10.35.1.11");
f31051bd
RH
38
39 // server = CameraServer.getInstance();
40 // axisCamera = cameraServer2.addAxisCamera("axisCamera", "10.35.1.11");
41 // cameraFeeds = new CameraFeeds();
e63d823c
ME
42 }
43
44 public void init() {
45 changeCam(intakeCam);
46 }
47
48 public void run()
49 {
a1a9bb70 50 if(/*add test for toggle*/)
e63d823c
ME
51 changeCam(intakeCam);
52
a1a9bb70 53 if(/*add test for toggle*/)
e63d823c
ME
54 changeCam(climberCam);
55
56 updateCam();
57 }
58
59 /**
60 * Stop aka close camera stream
61 */
62 public void end() {
63 NIVision.IMAQdxStopAcquisition(curCam);
64 }
65
66 /**
cdcbf5c6 67 *
e63d823c
ME
68 * Change the camera to get imgs from to a different one
69 *
70 * @param newId
71 * for camera
72 */
cdcbf5c6 73 public void changeCam(/* int newId */) {
18f2b59b
RH
74 if (curCam = true) {
75 public void removeCamera(/*Axis Camera name*/);
76 public void addCamera(VideoSource intakeCam);
77 curCam = false;
78 } else if (curCam = false) {
79 public void removeCamera(/*Usb Camera name*/);
80 public void addCamera(VideoSource climberCam);
81 curCam = false;
82 }
cdcbf5c6
RH
83 // NIVision.IMAQdxStopAcquisition(curCam);
84 // NIVision.IMAQdxConfigureGrab(newId);
85 // NIVision.IMAQdxStartAcquisition(newId);
86 // curCam = newId;
e63d823c
ME
87 }
88
89 /**
90 * Get the img from current camera and give it to the server
91 */
92 public void updateCam() {
93 NIVision.IMAQdxGrab(curCam, frame, 1);
cdcbf5c6 94 server.setImage(frame);
e63d823c
ME
95 }
96}