You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following example a thread created in robotInit() gets the Camera Server instance. Each frame of the video is individually processed, in this case converting a color image (BGR) to gray scale using the OpenCV cvtColor() method. The resultant images are then passed to the output stream and sent to the dashboard. You can replace the cvtColor operation with any image processing code that is necessary for your application. You can even annotate the image using OpenCV methods to write targeting information onto the image being sent to the dashboard.
32
+
In the following example a thread created in robotInit() gets the Camera Server instance. Each frame of the video is individually processed, in this case drawing a rectangle on the image using the OpenCV ``rectangle()`` method. The resultant images are then passed to the output stream and sent to the dashboard. You can replace the ``rectangle`` operation with any image processing code that is necessary for your application. You can even annotate the image using OpenCV methods to write targeting information onto the image being sent to the dashboard.
46
33
47
34
.. tabs::
48
35
49
-
.. code-tab:: java
50
-
51
-
package org.usfirst.frc.team190.robot;
52
-
53
-
import org.opencv.core.Mat;
54
-
import org.opencv.imgproc.Imgproc;
55
-
56
-
import edu.wpi.cscore.CvSink;
57
-
import edu.wpi.cscore.CvSource;
58
-
import edu.wpi.cscore.UsbCamera;
59
-
import edu.wpi.first.cameraserver.CameraServer;
60
-
import edu.wpi.first.wpilibj.IterativeRobot;
61
-
62
-
public class Robot extends IterativeRobot {
63
-
64
-
public void robotInit() {
65
-
new Thread(() -> {
66
-
UsbCamera camera = CameraServer.startAutomaticCapture();
Notice that in these examples, the ``PutVideo()`` method writes the video to a named stream. To view that stream on Shuffleboard, select that named stream. In this case that is "Blur" for the Java program and "Gray" for the C++ sample.
Notice that in these examples, the ``PutVideo()`` method writes the video to a named stream. To view that stream on SmartDashboard or Shuffleboard, select that named stream. In this case that is "Rectangle".
0 commit comments