Go to Post lets get FIRST in every home around the world, and a robot in every school. - Rohith Surampudi [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 20-01-2013, 14:29
Gmercer Gmercer is offline
Registered User
None #1631
 
Join Date: Jan 2013
Location: Las Vegas
Posts: 15
Gmercer is an unknown quantity at this point
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:

Code:
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):

Last edited by Gmercer : 20-01-2013 at 14:34.
  #2   Spotlight this post!  
Unread 20-01-2013, 20:29
GrimmReaper's Avatar
GrimmReaper GrimmReaper is offline
Registered User
FRC #2046 (Bear Metal)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Maple Valley, WA
Posts: 24
GrimmReaper is on a distinguished road
Re: Finding the HSL Threshold for my reflective tape

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!

  #3   Spotlight this post!  
Unread 20-01-2013, 23:15
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Finding the HSL Threshold for my reflective tape

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
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:15.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi