Change axis camera to usb camera.
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / CameraFeeds.java
CommitLineData
409d6878
ME
1package org.usfirst.frc.team3501.robot;
2
2ada01fd 3import edu.wpi.cscore.UsbCamera;
409d6878
ME
4import edu.wpi.first.wpilibj.CameraServer;
5
6public class CameraFeeds {
50a075d8
RH
7 // private final int intakeCam;
8 // private final int climberCam;
570ccbd9 9 private String curCam;
409d6878 10 private CameraServer server;
50a075d8 11 private static UsbCamera intakeCam;
2c6d3e5f
RH
12 private static UsbCamera climberCam;
13 private static String intakeCamName;
14 private static String climberCamName;
4bc0cb18 15 private static CameraFeeds cameraFeeds = null;
409d6878 16
fbc1210e 17 @SuppressWarnings("deprecation")
9ea6a533 18 private CameraFeeds(/* Joystick Button */) {
55391ba3 19 System.out.println("Enter CameraFeeds constructor");
409d6878 20 server = CameraServer.getInstance();
2c6d3e5f 21 climberCam = server.startAutomaticCapture();
4dff9cc3 22 intakeCam = server.startAutomaticCapture();
2c6d3e5f
RH
23 intakeCamName = intakeCam.getName();
24 climberCamName = climberCam.getName();
570ccbd9 25 curCam = "intakeCam";
55391ba3 26 System.out.println("Leaving CameraFeeds constructor");
409d6878 27 }
7638f542 28
4bc0cb18 29 public static CameraFeeds getCameraFeeds() {
55391ba3 30 System.out.println("Enter CameraFeeds.getCameraFeeds");
7638f542
RH
31 if (cameraFeeds == null) {
32 cameraFeeds = new CameraFeeds();
33 }
55391ba3 34 System.out.println("Leaving CameraFeeds.getCameraFeeds");
7638f542 35 return cameraFeeds;
4bc0cb18 36 }
409d6878
ME
37
38 public void init() {
55391ba3 39 System.out.println("Initializing...");
409d6878
ME
40 }
41
4dff9cc3 42 public void toggleCamera() {
570ccbd9 43 changeCam();
409d6878
ME
44 }
45
46 /**
50a075d8 47 *
4bc0cb18 48 * Change the camera to get image from to a different one
409d6878 49 *
7638f542 50 * newId for camera
409d6878 51 */
570ccbd9
RH
52 public void changeCam() {
53 System.out.println("enter toggleCamera");
54 if (curCam == "intakeCam") {
2c6d3e5f 55 server.getVideo(climberCamName);
570ccbd9
RH
56 curCam = "climberCam";
57 System.out.println("Switching to climber camera, curCam = " + curCam);
58 } else if (curCam == "climberCam") {
2c6d3e5f 59 server.getVideo(intakeCamName);
570ccbd9
RH
60 curCam = "intakeCam";
61 System.out.println("Switching to intake camera, curCam = " + curCam);
62 }
409d6878
ME
63 }
64}