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