Tweaked SmartDashboard for Image Overlays

We’ve been playing around with the SmartDashboard code to add support for image overlays to help debug vision code. It’s somewhat basic at the moment, and we’re planning on improving it, but what’s there is already a huge help. Essentially, it allows you to send a list of targets back over the SmartDashboard connection that are rendered onto the camera image.

Right now it just draws black bounding boxes around the targets sent back, but we’re planning on allowing you to specify colors and shapes to help differentiate the targets. It’s also a little bit hacky and likes to display a couple of extra fields on the dashboard, but the “__overlay” fields can be shoved into a corner without causing any problems.

I’m a lazy programmer, so the modifications don’t have a C++ counterpart, and I haven’t sent a patch to the SmartDashboard guys, although that’s something I’d like to do in the near future.

Anyway, if anyone wants to give it a go, just do a subversion checkout:

It’s a NetBeans project, so just open it (or check it out from svn directly within netbeans) and hit the run button. That’s the only setup for the client side.

As for the robot, you’ll need to grab this file (also svn, but just grabbing it works fine too – it’s just one file). In the source folder for your robot code, make the folder structure edu -> wpi -> first -> wpilibj, and place the there.

The only major change needed to robot code is to make sure you use the “ModdedSmartDashboard” class in place of “SmartDashboard” - using both (even in different parts of your code) will probably cause problems. Then, wherever you can get access to a ParticleAnalysisReport or something with target x/y/width/height, add:

ModdedSmartDashboard.startOverlay(); // do this before sending new targets to clear any old target overlays

ParticleAnalysisReport r; // get this from somewhere or use your own data
ModdedSmartDashboard.overlay(r.center_mass_x, r.center_mass_y, r.boundingRectWidth, r.boundingRectHeight);

If you don’t use this bit of the NI Vision libs, make sure to use center x/y coordinates rather than the usual top-left. They’re automatically converted to normal display coordinates on the client.

Anyway, hopefully somebody out there can find this useful!

This sounds really useful. I’m surprised a lot more folks are not hopping on this bandwagon. We are pulling our hair out trying to figure out why the tracking algorithm ( is producing so many particles. It would be really nice to be able to see the particle bounding boxes overlaid on top of the image (or better yet the processed, binary image).

We got spoiled working with RoboRealm software (project outside of FIRST). It does this for you automatically.

Anyway, we here at Team 3863 fully support your efforts. Thank you and let us know about any updates.

Glad to hear you find this useful!

We’ve pushed some new updates to clean up the dashboard itself (better theme, standardized field labels, etc) that also allows colored overlays. It’s great for coloring particles that meet certain parameters (size, quality, position, etc) and the like. I’ll be updating to original post with the new info soon.

Edit: or not, guess you can’t edit opening posts or something to that extent…

Anyway, there’s one new file added with predefined color constants: here has also been updated (same link as before). New changes include…

  • a “getColorCode(int red, int green, int blue)” method for converting RGB values into single-int form (needed to sent to the dashboard.
  • new “overlay(int x, int y, int width, int height, int color)” method that allows you to specify the color. The “color” parameter is optional and defaults to black if not specified.

The dashboard has also been tweaked, you can just “svn update” to get the updates. If there’s any, well, weirdness… we may have gotten a bit bored while waiting around, so there’s a chance some unexpected surprises may pop up (hopefully not though).

Again, hopefully this can help out some other teams!