public CameraServers(String... camNamesInput) { cams=new USBCamera[camNamesInput.length]; camNames=camNamesInput; m_quality = 50; m_camera = null; m_imageData = null; m_imageDataPool = new ArrayDeque<>(3); for (int i = 0; i < 3; i++) { m_imageDataPool.addLast(ByteBuffer.allocateDirect(kMaxImageSize)); } serverThread = new Thread(new Runnable() { public void run() { try { serve(); } catch (IOException e) { // do stuff here } catch (InterruptedException e) { // do stuff here } } }); serverThread.setName("CameraServer Send Thread"); serverThread.start(); }
private synchronized void startBroadcast(USBCamera camera) { if (m_autoCaptureStarted) return; m_autoCaptureStarted = true; m_camera = camera; m_camera.startCapture(); Thread captureThread = new Thread(new Runnable() { @Override public void run() { capture(); } }); captureThread.setName("Camera Capture Thread"); captureThread.start(); }
public synchronized void startAutomaticCapture(USBCamera camera) { if (m_autoCaptureStarted) return; m_autoCaptureStarted = true; m_camera = camera; m_camera.startCapture(); Thread captureThread = new Thread(new Runnable() { @Override public void run() { capture(); } }); captureThread.setName("Camera Capture Thread"); captureThread.start(); }
/** * Start automatically capturing images to send to the dashboard. * * You should call this method to just see a camera feed on the dashboard * without doing any vision processing on the roboRIO. {@link #setImage} * shouldn't be called after this is called. * * @param cameraName The name of the camera interface (e.g. "cam1") */ public void startAutomaticCapture(String cameraName) { try { USBCamera camera = new USBCamera(cameraName); camera.openCamera(); startAutomaticCapture(camera); } catch (VisionException ex) { //DriverStation.reportError( // "Error when starting the camera: " + cameraName + " " + ex.getMessage(), true); } }
public synchronized void startAutomaticCapture(USBCamera... camera) { if (m_camera.length == 0 || m_autoCaptureStarted) return; m_autoCaptureStarted = true; m_camera = camera; boolean hasFailed = false; for (int i = 0; i < m_camera.length; i++) { try { m_camera[selectedCamera].startCapture(); hasFailed = false; break; // If this is reached, } catch (VisionException e) { hasFailed = true; } } if (hasFailed) return; Thread captureThread = new Thread(new Runnable() { @Override public void run() { capture(); } }); captureThread.setName("Camera Capture Thread"); captureThread.start(); }
public void robotInit() { // Create subsystems drive = new Drive(); intake = new Intake(); arm = new Arm(); shooter = new Shooter(); hanger = new Hanger(); oi = new OI(); // Create motion profiles crossLowBar = new Profile(AutoMap.crossLowBar); reach = new Profile(AutoMap.reach); toShoot = new Profile(AutoMap.toShoot); toLowGoal = new Profile(AutoMap.toLowGoal); // Pick an auto chooser = new SendableChooser(); chooser.addDefault("Do Nothing", new DoNothing()); chooser.addObject("Low Bar", new LowBarRawtonomous()); chooser.addObject("Low Bar (profile)", new CrossLowBar(crossLowBar)); chooser.addObject("Reach", new Reach(reach)); chooser.addObject("Forward Rawto", new ForwardRawtonomous()); chooser.addObject("Backward Rawto", new BackwardRawtonomous()); chooser.addObject("Shoot", new AutoShoot()); SmartDashboard.putData("Auto mode", chooser); // Start camera stream camera = new USBCamera(); server = CameraServer.getInstance(); server.setQuality(40); server.startAutomaticCapture(camera); // Start compressor compressor = new Compressor(); compressor.start(); navx = new AHRS(SPI.Port.kMXP); }
/** * Start automatically capturing images to send to the dashboard. * * You should call this method to just see a camera feed on the dashboard * without doing any vision processing on the roboRIO. {@link #setImage} * shouldn't be called after this is called. * * @param cameraName The name of the camera interface (e.g. "cam1") */ private USBCamera startCamera(String cameraName) { try { USBCamera camera = new USBCamera(cameraName); camera.openCamera(); //startAutomaticCapture(camera); return camera; } catch (VisionException ex) { DriverStation.reportError( "Error when starting the camera: " + cameraName + " " + ex.getMessage(), true); } return null; }
/** * Start automatically capturing images to send to the dashboard. * * You should call this method to just see a camera feed on the dashboard * without doing any vision processing on the roboRIO. {@link #setImage} * shouldn't be called after this is called. * * @param cameraName The name of the camera interface (e.g. "cam1") */ public void startAutomaticCapture(String cameraName) { try { USBCamera camera = new USBCamera(cameraName); camera.openCamera(); startAutomaticCapture(camera); } catch (VisionException ex) { DriverStation.reportError( "Error when starting the camera: " + cameraName + " " + ex.getMessage(), true); } }
public static void initCameras() { if (init) return; bowCam = new USBCamera("cam0"); sternCam = new USBCamera("cam1"); //targetCam = new USBCamera("cam2"); init = true; }
private TurtwigDoubleVision() { try { sendImage = NIVision.imaqCreateImage(ImageType.IMAGE_RGB, 0); cameras.add(new USBCamera("cam0")); } catch (Exception e) { TurtleLogger.critical("Camera Not found"); e.printStackTrace(); } }
/** * Start automatically capturing images to send to the dashboard. You should * call this method to just see a camera feed on the dashboard without doing * any vision processing on the roboRIO. {@link #setImage} shouldn't be called * after this is called. This overload calles * {@link #startAutomaticCapture(String)} with the default camera name */ public void startAutomaticCapture() { startAutomaticCapture(USBCamera.kDefaultCameraName); }