Acquiring distance using axis camera

I am with team 3487. We are trying to use an axis camera to find the basketball goals for the 2012 FRC competition. We would also like to find the amount of pixels between the top and bottom goal and using some trig calculate our distance from the goal. We are stuck with coding the camera to find the image and then find the pixels in between. Are there any suggestions as to make this process easier.

Hi, I am from team 467 and I am the programmer who is working on the code for the camera. My first recommendation would be to read the paper published by National Instruments, here is a link to download the paper:
I recommend following the paper up until the point where they do the convex hull operation. There are two reasons for this, because there is no convex hull operation in the library for Java, and because this makes you unable to do a quality filter as I explained later. Instead of the convex hull you should put a filter on the particles the camera sees so you only get the particles that fall into the correct ratio of width to height (which is about 1.33) and fall into the correct quality range (quality is the total area of the bounding box of the particle divided by the total area of the particle) which should be around 30%. Both these functions can be found in the ParticleAnalysisReport class. From this point you can find the center of the backboard setup by getting the center of mass for all four particles. You could even find how far away from the boards the robot is by doing math on the width and height of the particle bounding boxes instead of trying to find the distance between the rectangles. You may not get very good results at first, but keep messing with the thresholds in the NI Vision Assistant software you got in the kit until you get a good image to do processing on.
Good Luck!