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()).