View Full Version : How to get rectangles to display on Camera Dashboard
Crzycoco
10-02-2014, 20:18
Hello fellow robotics comrades!
Our team is programming in Java this year and we decided to utilize Vision Processing our camera (Axis M1011). We have our green LED ring hook up on our camera and we got the code for Vision Processing from the Sample Project found in this years java sources. We adjusted the HSV using NI Vision and our camera is able to find the reflective tape that we measured precisely to what the reflective tape is going to be like in the competition. We confirmed this by putting a smartDashboard out for the method hotOrNot() since it returns a boolean whether the target is found.
So tl;dr our code works. So basically, how do I get rectangles to show around the reflective tape our driverstation? Kinda like this. (http://s3.amazonaws.com/screensteps_live/images/Wpilib/90361/7/rendered/bcde3949-5db8-4afa-a2dc-8b8ea1456ef0.png?AWSAccessKeyId=AKIAJRW37ULKKSXWY7 3Q&Expires=1392167840&Signature=CwFtPjzQGC9mRC6emnwxZpsb4Mg%3D) Do we need to download some sort of dashboard ti download or add code for it to be able to? Please guide us the way!!
Go US First!! :cool: :cool:
One possibility (what we did last year) - in your image processing code, push the information about rectangles (position, size) into a NetworkTable (http://wpilib.screenstepslive.com/s/3120/m/7912/l/80205-writing-a-simple-networktables-program-in-c-and-java-with-a-java-client-pc-side). Then, write a SmartDashboard widget (http://firstforge.wpi.edu/sf/wiki/do/viewPage/projects.smartdashboard/wiki/Extensions) with a transparent background that reads this information and draws rectangles. Manually drag this overlay to align with the camera feed.
Crzycoco
11-02-2014, 12:58
Thanks! I was able to make a widget that creates the rectangle but I don't know the variable from the camera code that determines the width and height of the reflective tape as seen by the camera. I also don't know the variable that returns the x and y coordinates of the where the reflective tape is located as seen from the camera. Any help is greatly appreciated!:]
So we are hosting a practice scrimmage and we attempted using tape from other years. The new could be picked up immediately, but the old did not even register. We are wondering if it was the spray adhesive we used to attached to the board or if it is a different makeup from the new tape.
Thanks! I was able to make a widget that creates the rectangle but I don't know the variable from the camera code that determines the width and height of the reflective tape as seen by the camera. I also don't know the variable that returns the x and y coordinates of the where the reflective tape is located as seen from the camera. Any help is greatly appreciated!:]
The information about rectangle size and position is contained in the corresponding ParticleAnalysisReport object - there are four members we are interested in: boundingRectTop, boundingRectLeft, boundingRectHeight, and boundingRectWidth.
Looking at the sample vision project, you can do this in the conditional where it checks for a hot target. Something along the lines of:
if(target.Hot)
{
System.out.println("Hot target located");
System.out.println("Distance: " + distance);
NetworkTable table = NetworkTable.getTable("VisionTarget");
ParticleAnalysisReport verticalReport = filteredImage.getParticleAnalysisReport(target.ver ticalIndex);
ParticleAnalysisReport horizontalReport = filteredImage.getParticleAnalysisReport(target.hor izontalIndex);
table.putNumber("vertTop", verticalReport.boundingRectTop);
table.putNumber("vertLeft", verticalReport.boundingRectLeft);
table.putNumber("vertHeight", verticalReport.boundingRectHeight);
table.putNumber("vertWidth", verticalReport.boundingRectWidth);
table.putNumber("horzTop", horizontalReport.boundingRectTop);
table.putNumber("horzLeft", horizontalReport.boundingRectLeft);
table.putNumber("horzHeight", horizontalReport.boundingRectHeight);
table.putNumber("horzWidth", horizontalReport.boundingRectWidth);
} else {
System.out.println("No hot target present");
System.out.println("Distance: " + distance);
}
Then, you can use this pattern in your widget to read from the same NetworkTable:
ITable table = table = (NetworkTable) Robot.getTable("VisionTarget");
int top = (int) table.getNumber("vertTop");
int left = (int) table.getNumber("vertLeft");
int width = (int) table.getNumber("vertWidth");
int height = (int) table.getNumber("vertHeight");
Greg McKaskle
11-02-2014, 21:12
If you want to verify the tape's retro-reflectivity, a cell phone with the flash turned on works quite well. I use this at events to identify if any other materials in the arena are retroreflective and need to be covered.
You can put the two types of tape near one another and verify whether the tape is the issue. They should shine super-bright. Technically, they should be about 300 times brighter than a white paint sample, but that will be hard to verify. Similarly, an image of the two tapes near one another using the ring light and the Axis camera is an even better test for what the robots will measure.
Greg McKaskle
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.