timothyb89
16-02-2011, 19:41
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:
https://lhrobotics.svn.sourceforge.net/svnroot/lhrobotics/trunk/sdbmod/
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 (https://lhrobotics.svn.sourceforge.net/svnroot/lhrobotics/trunk/y2011/src/edu/wpi/first/wpilibj/ModdedSmartDashboard.java) (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 ModdedSmartDashboard.java 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!
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:
https://lhrobotics.svn.sourceforge.net/svnroot/lhrobotics/trunk/sdbmod/
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 (https://lhrobotics.svn.sourceforge.net/svnroot/lhrobotics/trunk/y2011/src/edu/wpi/first/wpilibj/ModdedSmartDashboard.java) (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 ModdedSmartDashboard.java 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!