Yet another efficiency-increasing task would be to cut down on the amount of stuff that the frcParticleAnalysis function does. If you look at it (in VisionAPI.cpp), you can see that it does 9 calls to imaqMeasureParticle, which is an expensive function.
Here they are:
-center of mass x
-center of mass y (we might not need the y one, we don't use it right now and I don't see us using it in the future)
-area of particle
-4 calls to retrieve bounding rectangle: None of these are needed, we could just return the bounding rectangle that GetLargestParticle has already retrieved
-area by image area: this can be determined by dividing the area of the particle by the area of the image. Unless I misunderstand what this is, it is completely unnecessary
-particle quality: we don't use this right now, and might not in the future.
So we might be able to get frcParticleAnalysis down from 9 calls to imaqMeasureParticle to 2 by removing the bounding rect, particle quality, area %, and center-y calls. This should make for a substantial speedup.
If doing all that is too tough for lunch, just get a bunch of timing code in so we have a good idea of what we should target for improvements in FindColor. The faster FindColor is, the less laggy and more effective our camera response will be.