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