Commit | Line | Data |
---|---|---|
409d6878 ME |
1 | package org.usfirst.frc.team3501.robot; |
2 | ||
2ada01fd | 3 | import edu.wpi.cscore.UsbCamera; |
409d6878 ME |
4 | import edu.wpi.first.wpilibj.CameraServer; |
5 | ||
6 | public 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 RH |
25 | curCam = "intakeCam"; |
26 | changeCam(); | |
55391ba3 | 27 | System.out.println("Leaving CameraFeeds constructor"); |
409d6878 | 28 | } |
7638f542 | 29 | |
4bc0cb18 | 30 | public static CameraFeeds getCameraFeeds() { |
55391ba3 | 31 | System.out.println("Enter CameraFeeds.getCameraFeeds"); |
7638f542 RH |
32 | if (cameraFeeds == null) { |
33 | cameraFeeds = new CameraFeeds(); | |
34 | } | |
55391ba3 | 35 | System.out.println("Leaving CameraFeeds.getCameraFeeds"); |
7638f542 | 36 | return cameraFeeds; |
4bc0cb18 | 37 | } |
409d6878 ME |
38 | |
39 | public void init() { | |
55391ba3 | 40 | System.out.println("Initializing..."); |
409d6878 ME |
41 | } |
42 | ||
4dff9cc3 | 43 | public void toggleCamera() { |
570ccbd9 | 44 | changeCam(); |
409d6878 ME |
45 | } |
46 | ||
47 | /** | |
50a075d8 | 48 | * |
4bc0cb18 | 49 | * Change the camera to get image from to a different one |
409d6878 | 50 | * |
7638f542 | 51 | * newId for camera |
409d6878 | 52 | */ |
570ccbd9 RH |
53 | public void changeCam() { |
54 | System.out.println("enter toggleCamera"); | |
55 | if (curCam == "intakeCam") { | |
2c6d3e5f | 56 | server.getVideo(climberCamName); |
570ccbd9 RH |
57 | curCam = "climberCam"; |
58 | System.out.println("Switching to climber camera, curCam = " + curCam); | |
59 | } else if (curCam == "climberCam") { | |
2c6d3e5f | 60 | server.getVideo(intakeCamName); |
570ccbd9 RH |
61 | curCam = "intakeCam"; |
62 | System.out.println("Switching to intake camera, curCam = " + curCam); | |
63 | } | |
409d6878 ME |
64 | } |
65 | } |