View Single Post
  #5   Spotlight this post!  
Unread 11-02-2014, 18:24
irvingc irvingc is offline
Registered User
FRC #0948 (Newport Robotics Group)
Team Role: Leadership
 
Join Date: Jan 2014
Rookie Year: 2011
Location: Bellevue, WA
Posts: 31
irvingc is on a distinguished road
Re: How to get rectangles to display on Camera Dashboard

Quote:
Originally Posted by Crzycoco View Post
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:
Code:
if(target.Hot)
{
    System.out.println("Hot target located");
    System.out.println("Distance: " + distance);
    NetworkTable table = NetworkTable.getTable("VisionTarget");
    ParticleAnalysisReport verticalReport = filteredImage.getParticleAnalysisReport(target.verticalIndex);
    ParticleAnalysisReport horizontalReport = filteredImage.getParticleAnalysisReport(target.horizontalIndex);
    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:
Code:
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");
Reply With Quote