X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2FCameraFeeds.java;h=3ca36b32a355f839baee3ff82c2da49ec1121ce2;hb=b7b608d6e910666a101456fc3ce4ff1ec5b41d54;hp=c354594529961f38b6b252a003885bc4f740c830;hpb=1cac6c82d7cd42d210d46ae0edb59bc10f44ba26;p=3501%2F2017steamworks diff --git a/src/org/usfirst/frc/team3501/robot/CameraFeeds.java b/src/org/usfirst/frc/team3501/robot/CameraFeeds.java index c354594..3ca36b3 100755 --- a/src/org/usfirst/frc/team3501/robot/CameraFeeds.java +++ b/src/org/usfirst/frc/team3501/robot/CameraFeeds.java @@ -2,28 +2,44 @@ package org.usfirst.frc.team3501.robot; import com.ni.vision.NIVision; import com.ni.vision.NIVision.Image; + +import edu.wpi.cscore.AxisCamera; +import edu.wpi.cscore.UsbCamera; +import edu.wpi.cscore.VideoSource; import edu.wpi.first.wpilibj.CameraServer; public class CameraFeeds { - private final int intakeCam; - private final int climberCam; - private int curCam; + // private final int intakeCam; + // private final int climberCam; private Image frame; + private String curCam = "intake"; private CameraServer server; + private static UsbCamera intakeCam; + private static AxisCamera climberCam; - public CameraFeeds() { + @SuppressWarnings("deprecation") + public CameraFeeds(/* Joystick Button */) { // Get camera ids by supplying camera name ex 'cam0', found on roborio web // interface - intakeCam = NIVision.IMAQdxOpenCamera(Config.CameraFeeds.camNameCenter, - NIVision.IMAQdxCameraControlMode.CameraControlModeController); - climberCam = NIVision.IMAQdxOpenCamera(Config.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 + /* + * 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); + */ + intakeCam = CameraServer.getInstance().startAutomaticCapture(); + CameraServer.getInstance().startAutomaticCapture(); server = CameraServer.getInstance(); - server.setQuality(Config.CameraFeeds.imgQuality); + climberCam = server.addAxisCamera("axisCamera", "10.35.1.11"); + + // server = CameraServer.getInstance(); + // axisCamera = cameraServer2.addAxisCamera("axisCamera", "10.35.1.11"); + // cameraFeeds = new CameraFeeds(); } public void init() { @@ -45,27 +61,37 @@ public class CameraFeeds { * Stop aka close camera stream */ public void end() { - NIVision.IMAQdxStopAcquisition(curCam); + // NIVision.IMAQdxStopAcquisition(curCam); } /** + * * Change the camera to get imgs from to a different one * * @param newId * for camera */ - public void changeCam(int newId) { - NIVision.IMAQdxStopAcquisition(curCam); - NIVision.IMAQdxConfigureGrab(newId); - NIVision.IMAQdxStartAcquisition(newId); - curCam = newId; + public void changeCam(/* int newId */) { + if (curCam == "climber") { + server.removeCamera(/* Axis Camera name */); + server.addCamera(intakeCam); + curCam = "intake"; + } else if (curCam == "intake") { + server.removeCamera(/* Usb Camera name */); + server.addCamera(climberCam); + curCam = "climber"; + } + // NIVision.IMAQdxStopAcquisition(curCam); + // NIVision.IMAQdxConfigureGrab(newId); + // NIVision.IMAQdxStartAcquisition(newId); + // curCam = newId; } /** * Get the img from current camera and give it to the server */ public void updateCam() { - NIVision.IMAQdxGrab(curCam, frame, 1); - server.setImage(frame); + // NIVision.IMAQdxGrab(curCam, frame, 1); + // server.setImage(frame); } }