package org.usfirst.frc.team3501.robot;
-import com.ni.vision.NIVision.Image;
-
import edu.wpi.cscore.AxisCamera;
import edu.wpi.cscore.UsbCamera;
import edu.wpi.cscore.VideoSource;
public class CameraFeeds {
// private final int intakeCam;
// private final int climberCam;
- private Image frame;
private VideoSource curCam;
private CameraServer server;
private static UsbCamera intakeCam;
private static AxisCamera climberCam;
private static String usbCamName;
private static String axisCamName;
+ private static CameraFeeds cameraFeeds = null;
@SuppressWarnings("deprecation")
- public CameraFeeds(/* Joystick Button */) {
- // Get camera ids by supplying camera name ex 'cam0', found on roborio web
- // interface
- /*
- * intakeCam =
- * NIVision.IMAQdxOpenCamera(Constants.CameraFeeds.camNameCenter,
- * NIVision.IMAQdxCameraControlMode.CameraControlModeController); climberCam
- * = NIVision.IMAQdxOpenCamera(Constants.CameraFeeds.camNameRight,
- * NIVision.IMAQdxCameraControlMode.CameraControlModeController); curCam =
- * intakeCam; // Img that will contain camera img frame =
- * NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0); // Server that
- * we'll give the img to server = CameraServer.getInstance();
- * server.setSize(Constants.CameraFeeds.imgQuality);
- */
-
+ private CameraFeeds(/* Joystick Button */) {
+ System.out.println("Enter CameraFeeds constructor");
server = CameraServer.getInstance();
- climberCam = server.addAxisCamera("axisCamera", "10.35.1.11");
+ climberCam = server.addAxisCamera("AxisCamera", "10.35.1.11");
intakeCam = server.startAutomaticCapture();
- curCam = intakeCam;
usbCamName = intakeCam.getName();
axisCamName = climberCam.getName();
+ curCam = climberCam;
+ changeCam(curCam);
+ System.out.println("Leaving CameraFeeds constructor");
+ }
- // server = CameraServer.getInstance();
- // axisCamera = cameraServer2.addAxisCamera("axisCamera", "10.35.1.11");
- // cameraFeeds = new CameraFeeds();
+ public static CameraFeeds getCameraFeeds() {
+ System.out.println("Enter CameraFeeds.getCameraFeeds");
+ if (cameraFeeds == null) {
+ cameraFeeds = new CameraFeeds();
+ }
+ System.out.println("Leaving CameraFeeds.getCameraFeeds");
+ return cameraFeeds;
}
public void init() {
- changeCam(intakeCam);
+ System.out.println("Initializing...");
}
public void toggleCamera() {
+ System.out.println("enter toggleCamera");
if (curCam.equals(intakeCam)) {
changeCam(climberCam);
curCam = climberCam;
- }
-
- if (curCam.equals(climberCam)) {
+ System.out.println("Switching to climber camera.");
+ } else if (curCam.equals(climberCam)) {
changeCam(intakeCam);
curCam = intakeCam;
+ System.out.println("Switching to intake camera.");
}
}
/**
*
- * Change the camera to get imgs from to a different one
+ * Change the camera to get image from to a different one
*
- * @param newId
- * for camera
+ * newId for camera
*/
public void changeCam(VideoSource cam) {
- server.removeCamera(axisCamName);
- server.removeCamera(usbCamName);
- server.addCamera(cam);
+ System.out.println("Changing cameras...");
+ server.getVideo(cam);
}
}