Created
November 29, 2016 03:50
-
-
Save AustinShalit/e652a2508cca0bbd6a808f6c30b67830 to your computer and use it in GitHub Desktop.
CameraServer Example (OpenCV)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.usfirst.frc.team190.robot; | |
import org.opencv.core.Mat; | |
import org.opencv.imgproc.Imgproc; | |
import edu.wpi.cscore.CvSink; | |
import edu.wpi.cscore.CvSource; | |
import edu.wpi.cscore.USBCamera; | |
import edu.wpi.first.wpilibj.CameraServer; | |
import edu.wpi.first.wpilibj.IterativeRobot; | |
public class Robot extends IterativeRobot { | |
public void robotInit() { | |
new Thread(() -> { | |
USBCamera camera = CameraServer.getInstance().startAutomaticCapture(); | |
camera.setResolution(640, 480); | |
CvSink cvSink = CameraServer.getInstance().getVideo(); | |
CvSource outputStream = CameraServer.getInstance().putVideo("Blur", 640, 480); | |
Mat source = new Mat(); | |
Mat output = new Mat(); | |
while(true) { | |
cvSink.grabFrame(source); | |
Imgproc.cvtColor(source, output, Imgproc.COLOR_BGR2GRAY); | |
outputStream.putFrame(output); | |
} | |
}).start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment