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; | |
409d6878 ME |
8 | import edu.wpi.first.wpilibj.CameraServer; |
9 | ||
10 | public class CameraFeeds { | |
50a075d8 RH |
11 | // private final int intakeCam; |
12 | // private final int climberCam; | |
13 | private Image frame; | |
5a977fcf | 14 | private boolean curCam = true; |
409d6878 | 15 | private CameraServer server; |
50a075d8 RH |
16 | private static UsbCamera intakeCam; |
17 | private static AxisCamera climberCam; | |
409d6878 | 18 | |
fbc1210e | 19 | @SuppressWarnings("deprecation") |
50a075d8 | 20 | public CameraFeeds(/* Joystick Button */) { |
409d6878 ME |
21 | // Get camera ids by supplying camera name ex 'cam0', found on roborio web |
22 | // interface | |
50a075d8 RH |
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(); | |
409d6878 | 36 | server = CameraServer.getInstance(); |
50a075d8 | 37 | climberCam = server.addAxisCamera("axisCamera", "10.35.1.11"); |
2ada01fd RH |
38 | |
39 | // server = CameraServer.getInstance(); | |
40 | // axisCamera = cameraServer2.addAxisCamera("axisCamera", "10.35.1.11"); | |
41 | // cameraFeeds = new CameraFeeds(); | |
409d6878 ME |
42 | } |
43 | ||
44 | public void init() { | |
45 | changeCam(intakeCam); | |
46 | } | |
47 | ||
48 | public void run() | |
49 | { | |
1cac6c82 | 50 | if(/*add test for toggle*/) |
409d6878 ME |
51 | changeCam(intakeCam); |
52 | ||
1cac6c82 | 53 | if(/*add test for toggle*/) |
409d6878 ME |
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 | /** | |
50a075d8 | 67 | * |
409d6878 ME |
68 | * Change the camera to get imgs from to a different one |
69 | * | |
70 | * @param newId | |
71 | * for camera | |
72 | */ | |
50a075d8 | 73 | public void changeCam(/* int newId */) { |
5a977fcf RH |
74 | if (curCam = true) { |
75 | public void removeCamera(/*Axis Camera name*/); | |
76 | public void addCamera(VideoSource intakeCam); | |
77 | curCam = false; | |
78 | } else if (curCam = false) { | |
79 | public void removeCamera(/*Usb Camera name*/); | |
80 | public void addCamera(VideoSource climberCam); | |
81 | curCam = false; | |
82 | } | |
50a075d8 RH |
83 | // NIVision.IMAQdxStopAcquisition(curCam); |
84 | // NIVision.IMAQdxConfigureGrab(newId); | |
85 | // NIVision.IMAQdxStartAcquisition(newId); | |
86 | // curCam = newId; | |
409d6878 ME |
87 | } |
88 | ||
89 | /** | |
90 | * Get the img from current camera and give it to the server | |
91 | */ | |
92 | public void updateCam() { | |
93 | NIVision.IMAQdxGrab(curCam, frame, 1); | |
50a075d8 | 94 | server.setImage(frame); |
409d6878 ME |
95 | } |
96 | } |