@Override public void robotInit() { RF = new RobotFunctions(); chooser.addDefault("Default Auto", defaultAuto); chooser.addObject("My Auto", customAuto); SmartDashboard.putData("Auto modes", chooser); UsbCamera camera = CameraServer.getInstance().startAutomaticCapture(); camera.setResolution(IMG_WIDTH, IMG_HEIGHT); visionThread = new VisionThread(camera, new Grip(), pipeline -> { if (pipeline.equals(null)) { Rect r = Imgproc.boundingRect(pipeline.filterContoursOutput().get(0)); synchronized (imgLock) { centerX = r.x + (r.width / 2);//Find the centre of the X Value centerY = r.y + (r.height / 2); rw = r.width; rh = r.height; } } }); visionThread.start(); }
public void setUpCamera(){ CameraServer.getInstance().startAutomaticCapture(); camera = CameraServer.getInstance().startAutomaticCapture(); //camera.setResolution(RobotMap.IMG_WIDTH, RobotMap.IMG_HEIGHT); //camera.setExposureManual(RobotMap.exposure); visionThread = new VisionThread(camera, new GripPipeline(), pipeline -> { if (!pipeline.filterContoursOutput().isEmpty()) { Rect r = Imgproc.boundingRect(pipeline.filterContoursOutput().get(0)); synchronized (imgLock) { centerX = r.x + (r.width / 2); } } }); }
public VisionTest() { UsbCamera camera = CameraServer.getInstance().startAutomaticCapture(); // cam0 by default camera.setResolution(IMG_WIDTH, IMG_HEIGHT); camera.setBrightness(0); // camera.setExposureManual(100); camera.setExposureAuto(); CvSource cs= CameraServer.getInstance().putVideo("name", IMG_WIDTH, IMG_HEIGHT); visionThread = new VisionThread(camera, new GripPipeline(), pipeline -> { Mat IMG_MOD = pipeline.hslThresholdOutput(); if (!pipeline.filterContoursOutput().isEmpty()) { //Rect recCombine = Imgproc.boundingRect(pipeline.filterContoursOutput().get(0)); Rect recCombine = computeBoundingRectangle(pipeline.filterContoursOutput()); if (recCombine == null) { targetDetected = false; return; } targetDetected = true; computeCoords(recCombine); synchronized (imgLock) { centerX = recCombine.x + (recCombine.width / 2); } Imgproc.rectangle(IMG_MOD, new Point(recCombine.x, recCombine.y),new Point(recCombine.x + recCombine.width,recCombine.y + recCombine.height), new Scalar(255, 20, 0), 5); } else { targetDetected = false; } cs.putFrame(IMG_MOD); }); visionThread.start(); Relay relay = new Relay(RobotMap.RELAY_CHANNEL, Direction.kForward); relay.set(Relay.Value.kOn); //this.processImage(); }
@Override public void robotInit() { chooser.addDefault("Default Auto", defaultAuto); chooser.addObject("My Auto", customAuto); SmartDashboard.putData("Auto modes", chooser); UsbCamera camera = CameraServer.getInstance().startAutomaticCapture(); camera.setResolution(IMG_WIDTH, IMG_HEIGHT); visionThread = new VisionThread(Camera, new mar4grip(), Pipeline -> { if (Pipeline.filterContoursOutput().isEmpty()) { Rect r = Imgproc.boundingRect(Pipeline.findContoursOutput().get(0)); centerX = r.x + (r.width / 2); } }); }
@Override public void robotInit() { chooser.addDefault("Default Auto", defaultAuto); chooser.addObject("My Auto", customAuto); SmartDashboard.putData("Auto modes", chooser); UsbCamera camera = CameraServer.getInstance().startAutomaticCapture(); camera.setResolution(IMG_WIDTH, IMG_HEIGHT); visionThread = new VisionThread(Camera, new Grippipeline(), pipeline -> { if (!pipeline.filterContoursOutput().isEmpty()) { Rect r = Imgproc.boundingRect(pipeline.findContoursOutput().get(0)); centerX = r.x + (r.width / 2); } }); }
/** * Instantiates BlastoiseVision with a VideoSource object. * This method is not recommended to be used directly, use one of the others instead. * @param videoSource */ public BlastoiseShooterVision(VideoSource videoSource) { this.videoSource = videoSource; videoSource.setResolution(Constants.ShooterVision.Camera.WIDTH_PX, Constants.ShooterVision.Camera.HEIGHT_PX); VisionThread visionThread = new VisionThread(videoSource, new DetectTargetPipeline(), pipeline -> { synchronized (lock) { processContours(pipeline.filterContours0Output()); } }); visionThread.start(); }