View Single Post
  #2   Spotlight this post!  
Unread 23-02-2012, 15:40
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Tracking Multiple Targets

Well, first of all, that code doesn't track multiple targets... It only tracks the lowest one. The most important part of the code for this topic is:
Code:
                for (int i = 0; i < reports.length; i++) {
                    if (reports[i].imageHeight > minSquareHeight && reports[i].center_mass_y > lowestSquare) {
                        lowestSquare = reports[i].center_mass_y;
                        lowSquareIndex = i;
                        System.out.println("Target: " + i + "  " + reports[i].center_mass_x + "," + reports[i].center_mass_y);
                    }
                }
Here you're going through all the particles (aka visible targets) and selecting the lowest one (the one with the greatest y value, since images have an inverted y axis). You're completely ignoring the rest.

On a slightly different topic, what are you trying to do with this?
Code:
reports[i].imageHeight > minSquareHeight
If you're trying to create a minimum threshold for the particle's height, this is not what it's doing. ParticleAnalysisReport.imageHeight is the height of the entire image, not the particle. For the height of the particle, you want ParticleAnalysisReport.boundingRectHeight. Although, if you want to create a size threshold, you're much better off using NIVision.particleFilter() (which is wrapped by BinaryImage.particleFilter()).
Reply With Quote