Finding the HSL Threshold for my reflective tape

Im currently progrmming an AxisCamera to pick up reflective tape and crop rectangle around the tape. i have most of the code down except for the parameters of the HSL Threshold, here is what i have:

public void cameraCapture() throws AxisCameraException, NIVisionException {
        if (joy1.getRawButton(3)) {
            ColorImage initImg;
            BinaryImage dataImg;
            ParticleAnalysisReport] particle;
            int trgCnt;
            SmartDashboard.putString("Taken Picture", "Picture begun...");
            if(camera.freshImage()) {
                initImg = camera.getImage();

                //RIGHT HERE
                dataImg = initImg.thresholdHSL(0, 0, 0, 0, 0, 0);   //set threshold to bright colors(UNFINISHED)
                //No clue how to find these parameters

                dataImg = dataImg.removeSmallObjects(false, 1);     //remove small pixles from image
                dataImg = dataImg.convexHull(false);                //fill in rectangles selected
                dataImg = dataImg.particleFilter(critCollection);   //filter rectangles
                trgCnt = dataImg.getNumberParticles();
                if(trgCnt > 0) {
                    particle = dataImg.getOrderedParticleAnalysisReports();
                    SmartDashboard.putString("Taken Picture", "binary mapping finished....calling Aim");
                    Aim(particle);
                } else {
                    SmartDashboard.putString("Taken Picture", "No particles to manipulate, picture was not taken?");
                }
                dataImg.free();
                initImg.free(); 
            }
        }
    }

i don’t know how to find the values. The function requires:

int hueLow
int hueHigh
int saturationLow
int saturationHigh
int luminenceLow
int luminenceHigh

I was told the NI tool “Particle Classification Training” would help, but i am not sure how to go about finding these limits of an image, how can i attain these values? Example image that i would use(im looking for the green boarder): http://dl.dropbox.com/u/78573135/IMAG0051.jpg

To find the threshold values whether RGB/HSL/Whatever I found it easiest to use the NI Vision Assistant, i believe it comes with the labview install, if you didn’t install labview you might be able to just install the Vision Assistant, but i’m not sure. Either way it’s pretty easy - either acquire an image from your axis camera directly into the VA or open an existing image like the one you posted.

Then go to “Process Images”
Then off the color menu choose color threshold
You can look at the image below for reference on the rest.

  1. Choose HSL(Blue arrow), you’ll see the H/S/L Histograms change to show those values

  2. Now (purple/green arrows) with your mouse select rectangular areas in the picture that represent what you want to select, you can hold down ctrl to select multiple areas. As you do this you’ll see the histograms change to only show the values of the are you selected (inclusive of all areas you chose)

  3. Now change the red/blue threshold markers on each histogram (dark red arrows) you can drag the blue/red lines or change the min/max values on each one. The spots on the image that match your threshold mark will get colored with the “preview color” default is red… So in the image below you can see i got most of your areas, but not parts of the left - their values are outside the thresholds so now i could just easily draw another box around the spots it didn’t get and expand the thresholds to catch it all…

I would also suggest you play with RGB thresholds, i found that worked best for us last year, especially with a green light.

Lastly you can test every operation you’re doing in code with vision assistant before you code it, if you click oK on the threshold, you’ll see that action added to the script list on the bottom right, then you can add each operation in serial to replicate your intended code then you can test the outcome and play with values for each operation to make sure they’ll work on the robot.

Have fun and good luck!

http://dl.dropbox.com/u/61715345/vision_settings_hsl.jpg

The only thing I’d add is to consider changing the Luminance upper all the way to 255 and consider adding a safety margin to the other edges of hue and saturation to make the values a bit more resilient.

Greg McKaskle