FIRST recently posted some code to track two colors (
http://joule.ni.com/nidu/cds/view/p/lang/en/id/1215). However, our team had already written similar code, and after comparing the two, we think that our team's code is easier to understand and perhaps even faster. The main difference (as far as I can tell) is that FIRST's code will move the camera to track the object while our code only returns a position.
In the spirit of gracious professionalism, we decided to make our team's code available to everyone. You're welcome to use this code and/or modify to suit your own team's needs. If you find anything wrong with our code*, please let us know as well. Also, you'll need to change the color value ranges and minimum area and distances.
*If you look at the image outputs, you might see that they "flicker" occasionally. We think this is only a problem with the image output because the numerical output parameters look fine.
EDIT: fixed parenthesis in link