Off Board Vision Processing in Java

This article describes how to get OpenCV, the WPILib Vision library, and NetworkTables, and how to build Java vision targeting programs that run on coprocessors that run alongside the roboRIO. This currently supports the following platforms:

  • Windows
  • Raspberry Pi running Raspbian
  • Generic Armhf devices (such as the BeagleBone Black or the Jetson)

It has been designed to be easy to setup and use, and only needs a few minor settings to pick which system you want to be ran on. It has samples for interfacing with NetworkTables and WPILib Vision Library (CsCore) from any device, along with performing OpenCV operations.

The system is setup to use Gradle to run the builds. Gradle is a cross platform build system, which only requires Java to run.

Getting Started

There are five steps to get your coprocessor configured for vision processing as shown below.  This is just a template.  You will need to add meaningful code to it for it to do what you want.  After following the steps in this document you will have a zip file that you can copy on to your coprocessor, extract, and run.

  1. You can develop your vision program on a laptop or your coprocessor. Download the zip file located at to the device where you want to do your development.
  2. Extract the zip and open a command prompt to the extracted folder

Selecting which system to build for

As there is no way to autodetect which system you want to build for, such as building for a Raspberry Pi on a windows desktop, you have to manually select which system you want to build for.

  1. Open the build.gradle file
  1. To select your device uncomment the line it is on by removing the //
  1. Save and exit

Selecting camera type

The sample includes 2 ways to get a camera image:

  1. Stream from roboRIO (HTTP Camera)
  2. USB Camera plugged into your coprocessor (not supported on Windows)

To select between the types, open the file in src/main/java, and scroll down to the line that says "Selecting a Camera".  Remove the block comments around the type of camera you are going to use.  If using the HTTP Camera, make sure to replace the "YourURLHere" with the URL to the stream of the camera.  In the screenshots below, we have selected a USB Camera.

Building and Running

This sample program only serves video as an http mjpg stream to a web browser or your SmartDashboard and serves as a template. To add your own vision code, edit the java file and add your code there.

To build the project, run the command ./gradlew build .  This will place the output files into the output directory.  From there, you can run either the .bat file on windows or the shell script on unix in order to run your project on the local system.  If you are programming on another computer, copy the zip file to the system you plan to run the vision code on, extract the zip file, and run the .bat or shell script to run the program.

Building Offline

An initial build with an internet connection is needed to download dependencies. After the initial build is complete, builds can be run without an internet connection by adding '--offline' to the build command:

./gradlew build --offline


You are not on the system you specified in the build.gradle file.  Please modify the build.gradle to match your system and run ./gradlew clean.

0 Report Errors

Use this form to report any errors with the documentation. For help with WPILib, please use the FIRST Forums at For reporting WPILib bugs, please submit an issue on GitHub at