Toggle between cameras (Untested).
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / CameraFeeds.java
CommitLineData
409d6878
ME
1package org.usfirst.frc.team3501.robot;
2
409d6878 3import com.ni.vision.NIVision.Image;
2ada01fd
RH
4
5import edu.wpi.cscore.AxisCamera;
6import edu.wpi.cscore.UsbCamera;
b7b608d6 7import edu.wpi.cscore.VideoSource;
409d6878
ME
8import edu.wpi.first.wpilibj.CameraServer;
9
10public class CameraFeeds {
50a075d8
RH
11 // private final int intakeCam;
12 // private final int climberCam;
13 private Image frame;
4dff9cc3 14 private VideoSource curCam;
409d6878 15 private CameraServer server;
50a075d8
RH
16 private static UsbCamera intakeCam;
17 private static AxisCamera climberCam;
4dff9cc3
RH
18 private static String usbCamName;
19 private static String axisCamName;
409d6878 20
fbc1210e 21 @SuppressWarnings("deprecation")
50a075d8 22 public CameraFeeds(/* Joystick Button */) {
409d6878
ME
23 // Get camera ids by supplying camera name ex 'cam0', found on roborio web
24 // interface
50a075d8
RH
25 /*
26 * intakeCam =
27 * NIVision.IMAQdxOpenCamera(Constants.CameraFeeds.camNameCenter,
28 * NIVision.IMAQdxCameraControlMode.CameraControlModeController); climberCam
29 * = NIVision.IMAQdxOpenCamera(Constants.CameraFeeds.camNameRight,
30 * NIVision.IMAQdxCameraControlMode.CameraControlModeController); curCam =
31 * intakeCam; // Img that will contain camera img frame =
32 * NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0); // Server that
33 * we'll give the img to server = CameraServer.getInstance();
34 * server.setSize(Constants.CameraFeeds.imgQuality);
35 */
4dff9cc3 36
409d6878 37 server = CameraServer.getInstance();
50a075d8 38 climberCam = server.addAxisCamera("axisCamera", "10.35.1.11");
4dff9cc3
RH
39 intakeCam = server.startAutomaticCapture();
40 curCam = intakeCam;
41 usbCamName = intakeCam.getName();
42 axisCamName = climberCam.getName();
2ada01fd
RH
43
44 // server = CameraServer.getInstance();
45 // axisCamera = cameraServer2.addAxisCamera("axisCamera", "10.35.1.11");
46 // cameraFeeds = new CameraFeeds();
409d6878
ME
47 }
48
49 public void init() {
50 changeCam(intakeCam);
51 }
52
4dff9cc3
RH
53 public void toggleCamera() {
54 if (curCam.equals(intakeCam)) {
409d6878 55 changeCam(climberCam);
4dff9cc3
RH
56 curCam = climberCam;
57 }
409d6878 58
4dff9cc3
RH
59 if (curCam.equals(climberCam)) {
60 changeCam(intakeCam);
61 curCam = intakeCam;
62 }
409d6878
ME
63 }
64
65 /**
50a075d8 66 *
409d6878
ME
67 * Change the camera to get imgs from to a different one
68 *
69 * @param newId
70 * for camera
71 */
4dff9cc3
RH
72 public void changeCam(VideoSource cam) {
73 server.removeCamera(axisCamName);
74 server.removeCamera(usbCamName);
75 server.addCamera(cam);
409d6878
ME
76 }
77}