Commit | Line | Data |
---|---|---|
e63d823c ME |
1 | package org.usfirst.frc.team3501.robot; |
2 | ||
e63d823c | 3 | import com.ni.vision.NIVision.Image; |
f31051bd RH |
4 | |
5 | import edu.wpi.cscore.AxisCamera; | |
6 | import edu.wpi.cscore.UsbCamera; | |
c826b6d1 | 7 | import edu.wpi.cscore.VideoSource; |
e63d823c ME |
8 | import edu.wpi.first.wpilibj.CameraServer; |
9 | ||
10 | public class CameraFeeds { | |
cdcbf5c6 RH |
11 | // private final int intakeCam; |
12 | // private final int climberCam; | |
13 | private Image frame; | |
9d04f601 | 14 | private VideoSource curCam; |
e63d823c | 15 | private CameraServer server; |
cdcbf5c6 RH |
16 | private static UsbCamera intakeCam; |
17 | private static AxisCamera climberCam; | |
9d04f601 RH |
18 | private static String usbCamName; |
19 | private static String axisCamName; | |
e63d823c | 20 | |
c6008874 | 21 | @SuppressWarnings("deprecation") |
cdcbf5c6 | 22 | public CameraFeeds(/* Joystick Button */) { |
e63d823c ME |
23 | // Get camera ids by supplying camera name ex 'cam0', found on roborio web |
24 | // interface | |
cdcbf5c6 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 | */ | |
9d04f601 | 36 | |
e63d823c | 37 | server = CameraServer.getInstance(); |
cdcbf5c6 | 38 | climberCam = server.addAxisCamera("axisCamera", "10.35.1.11"); |
9d04f601 RH |
39 | intakeCam = server.startAutomaticCapture(); |
40 | curCam = intakeCam; | |
41 | usbCamName = intakeCam.getName(); | |
42 | axisCamName = climberCam.getName(); | |
f31051bd RH |
43 | |
44 | // server = CameraServer.getInstance(); | |
45 | // axisCamera = cameraServer2.addAxisCamera("axisCamera", "10.35.1.11"); | |
46 | // cameraFeeds = new CameraFeeds(); | |
e63d823c ME |
47 | } |
48 | ||
49 | public void init() { | |
50 | changeCam(intakeCam); | |
51 | } | |
52 | ||
9d04f601 RH |
53 | public void toggleCamera() { |
54 | if (curCam.equals(intakeCam)) { | |
e63d823c | 55 | changeCam(climberCam); |
9d04f601 RH |
56 | curCam = climberCam; |
57 | } | |
e63d823c | 58 | |
9d04f601 RH |
59 | if (curCam.equals(climberCam)) { |
60 | changeCam(intakeCam); | |
61 | curCam = intakeCam; | |
62 | } | |
e63d823c ME |
63 | } |
64 | ||
65 | /** | |
cdcbf5c6 | 66 | * |
e63d823c ME |
67 | * Change the camera to get imgs from to a different one |
68 | * | |
69 | * @param newId | |
70 | * for camera | |
71 | */ | |
9d04f601 RH |
72 | public void changeCam(VideoSource cam) { |
73 | server.removeCamera(axisCamName); | |
74 | server.removeCamera(usbCamName); | |
75 | server.addCamera(cam); | |
e63d823c ME |
76 | } |
77 | } |