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(); }
public WsRelay(int moduleNumber, int channel, Direction direction) { relay = new Relay(moduleNumber, channel, direction); }