OCCRA
Go to Post To sum it up... We know nothing. - BJC [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Events   CD-Media   CD-Spy   FRC-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-03-2009, 05:42 AM
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
improvements to demo camera code anyone

Hi, I'm interested in how other teams have systematically improved the reliability of their goal seeking program from the demo code. Both mechanically and program-wise.

Like many other teams, we are having a harder time tracking the green than the pink. I heard that there is a tool called HSL that can be used to help improve the goal tracking, however I dont know where it is and how to use it.

Much appreciated!
Reply With Quote
  #2   Spotlight this post!  
Unread 02-03-2009, 07:09 AM
Jared Russell's Avatar
Jared Russell Jared Russell is offline
I feel better now.
AKA: Jared341
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 2,619
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: improvements to demo camera code anyone

HSL (and the related HSV) are different color spaces designed to represent "perceptual color relationships" better than RGB (red-green-blue). The idea is that you are breaking down a color into a hue, a saturation, and a lightness (or value). This representation is supposed to be more robust to variations in lighting.

However, converting to and from HSL/HSV is a fairly complicated operation. LabView and WindRiver should have code to do this for you already - just be warned that you don't want to be spending all your time converting between color spaces!

For more info: http://en.wikipedia.org/wiki/HSL_and_HSV
Reply With Quote
  #3   Spotlight this post!  
Unread 02-03-2009, 08:04 AM
Greg McKaskle Greg McKaskle is offline
Registered User
no team (Team NI)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 3,926
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: improvements to demo camera code anyone

The default code in both LV and C/C++ are already doing conversion to HSL. I'll speak about the LV example since I'm more familiar. The image passed into FindTwoColor first passes through an optional decimate/subset case. Next if debug HSL is on, it converts everything to HSL and displays on the panel in HSL so that you can hover and read pixel values out in HSL. By the way, don't leave this on or it will slow things down, it is for debugging.

Next it performs a color threshold. The image going in is normally an RGB, but the thresholds are spec'd in HSL, so as needed the pixels in your image will be converted for thresholding. To speed things up, it only converts the parts it needs. So the L is computed, and only if it passes is the S computed, and only if it passes is H computed. This gives the same results, but takes advantage of the speed of computing the elements.

Following this is particle analysis which returns area and bounding rect edges. The VI was written so that it would be easy to ask for more properties for the particles, perhaps the percent coverage or the ratio of the edges of the best rectangle fit.

The next step is looping through looking for a secondary in the right location to a primary. This involves subsetting the image and looking in the tiny areas for the second color.

Back to the original topic. I also want to hear what people have done to improve it. I just wanted to make sure it was clear what it currently does, like HSL, before starting to change it.

Greg McKaskle
Reply With Quote
  #4   Spotlight this post!  
Unread 02-03-2009, 08:31 AM
Jared Russell's Avatar
Jared Russell Jared Russell is offline
I feel better now.
AKA: Jared341
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 2,619
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: improvements to demo camera code anyone

Greg -

Since I would imagine that only the hue (H) component of the image is particularly useful for color matching, would computing only this coordinate of the color space improve speed at all?

Thanks
Reply With Quote
  #5   Spotlight this post!  
Unread 02-03-2009, 09:51 AM
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 7,809
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Send a message via AIM to Alan Anderson
Re: improvements to demo camera code anyone

Quote:
Originally Posted by Abwehr View Post
Since I would imagine that only the hue (H) component of the image is particularly useful for color matching, would computing only this coordinate of the color space improve speed at all?
Computing H from RGB is computationally expensive. Postponing it until the last possible time, and doing it only after the other parameters pass, is a good strategy for being efficient.
Reply With Quote
  #6   Spotlight this post!  
Unread 02-03-2009, 10:34 AM
Jared Russell's Avatar
Jared Russell Jared Russell is offline
I feel better now.
AKA: Jared341
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 2,619
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: improvements to demo camera code anyone

Forgive me if I'm being dense but...

Wouldn't the problem of converting a 24-bit RGB value into an 8 bit hue be a good candidate for a lookup table? You would have a 256x256x256 byte array. This is 16MB and should fall well-within the memory limitations of the cRIO. I'd gladly trade that memory for speed. The only sticking points would be (1) how much of the cRIO's memory is really available and (2) whether or not the C compiler would allow such a large array. If (2) is not satisfied, you could get around it with the clever use of pointers and multiple smaller arrays. If (1) is not satisfied, then we are stuck with what we have.
Reply With Quote
  #7   Spotlight this post!  
Unread 02-03-2009, 07:28 PM
Greg McKaskle Greg McKaskle is offline
Registered User
no team (Team NI)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 3,926
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: improvements to demo camera code anyone

First to your question about only using hue to threshold. The difference between inky black, navy blue, bright blue, pastel blue, and sky blue is not the hue, but the saturation and primarily the luminance. At the extremes, black and white are all hues, and in practice, they tent to be tinted by the lighting so they may all look blue for example, but saturation tells you how much blue.

As for doing a monster lookup table, it would be possible, but how fast does it need to be? We discussed this a bit, but decided to keep it simple. Put timing code in around the different elements and see what piece is most expensive.

Greg McKaskle
Reply With Quote
  #8   Spotlight this post!  
Unread 02-05-2009, 09:20 PM
Loubear's Avatar
Loubear Loubear is offline
Registered User
AKA: YLou
FRC #0075 (RoboRaiders)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2006
Location: NJ
Posts: 33
Loubear will become famous soon enoughLoubear will become famous soon enough
Re: improvements to demo camera code anyone

Actually, using hue alone to locate the red actually works pretty well. The reason being is that the red portion of the target returns extremely high hue values, in the range of 240-255. Once the red coordinates are down, the green should be easy to find.
Reply With Quote
  #9   Spotlight this post!  
Unread 02-05-2009, 10:25 PM
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: improvements to demo camera code anyone

We have had some sucess tracking the goals. We are experimenting with the Hue, Saturation, and Lima, but it feels like we are shooting in the dark. Can anyone provide some example settings of what has been working for them? Also has anyone approached tuning the HSL using a systematic approach? Thanks!
Reply With Quote
  #10   Spotlight this post!  
Unread 02-06-2009, 06:59 AM
Greg McKaskle Greg McKaskle is offline
Registered User
no team (Team NI)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 3,926
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: improvements to demo camera code anyone

As for using only hue, a white or black object in incandescent light may very well show 250 as well. The hue is an angular measurement by the way, and this is really just pointing in a direction on the color wheel saying (in the red family).

To continue my home improvement analogy for HSL, Let's say you are mixing paint. You add pigment to a base then shake the daylights out of it. The hue is the color of the pigment you add in. S is how much pigment you add, and L is the color of the base you start with (snow white, light gray, medium gray, dark gray, etc.)

So when you look at something like the target, it is clearly highly saturated, lots of color. If you take a little bit of that same color and add it to white paint, you'll get a softer color of exactly the same tint or hue. If you add it to gray paint, you get a pastel of the same hue.

As for being systematic, you can pretty easily do this for a particular lighting situation. You can take a few photos using the axis, and statistically measure the spread of HSL values that your target returns. You can decide how many additional std deviations to include for a safety margin. The problem is that when the lighting changes, your statistics aren't valid anymore. At least some of the numbers are not valid. Arguably, as you expose to additional lighting arrangements and types of lights and you merge the HSL sets you find, you ultimately wind up with the wide set of values the in the demo code.

So, are you asking because the demo code doesn't work well enough? Or because you want to tune it? Also, let me know if you are using LV or C.

Greg McKaskle
Reply With Quote
  #11   Spotlight this post!  
Unread 02-06-2009, 03:59 PM
Loubear's Avatar
Loubear Loubear is offline
Registered User
AKA: YLou
FRC #0075 (RoboRaiders)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2006
Location: NJ
Posts: 33
Loubear will become famous soon enoughLoubear will become famous soon enough
Re: improvements to demo camera code anyone

While white or black values show up every now then as above 250 on the hue scale under incandescent lighting and strange white balances, they usually come up in disconnected particles rather than homogeneous blobs. Even pointing my camera at the light (under all of the camera light settings) the most that is ever picked up gets removed with a particle filter.
Reply With Quote
  #12   Spotlight this post!  
Unread 02-06-2009, 04:51 PM
Greg McKaskle Greg McKaskle is offline
Registered User
no team (Team NI)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 3,926
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: improvements to demo camera code anyone

Quote:
While white or black values show up every now then as above 250 on the hue scale under incandescent lighting and strange white balances, they usually come up in disconnected particles rather than homogeneous blobs. Even pointing my camera at the light (under all of the camera light settings) the most that is ever picked up gets removed with a particle filter.
It is very easy to make white objects have any tint you like. Think of concert or theater lighting. Normal white lighting is less tinted, but the same concept applies. So if you want to go forward using only hue, that is your choice. I'm telling you it is a bad idea. Also, be sure you think of hue as an angle, not a magnitude. 250 happens to point to red, but 120 points to blue, and 70 points to green. These are arbitrary numbers, and what is important is how closely they match expected values, not that they get over 250. Also note that there is not hue on the color wheel for black or white or gray. Those colors are described by the other two elements in the HSL trio. It is a three dimensional system, and a single dimension doesn't describe a point.

Greg McKaskle
Reply With Quote
  #13   Spotlight this post!  
Unread 02-06-2009, 05:58 PM
Loubear's Avatar
Loubear Loubear is offline
Registered User
AKA: YLou
FRC #0075 (RoboRaiders)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2006
Location: NJ
Posts: 33
Loubear will become famous soon enoughLoubear will become famous soon enough
Re: improvements to demo camera code anyone

After a couple more tests, I realized that my initial reasons for not using sat and lum (I assumed both were as computationally intensive as hue) were pretty useless. So there's really no reason not to be using all three dimensions... if I'm using hue it's going to cost me anyways.

Thanks for the tips though, I'm somewhat new to this image processing stuff. Back to reading russ.
Reply With Quote
  #14   Spotlight this post!  
Unread 02-06-2009, 08:22 PM
Greg McKaskle Greg McKaskle is offline
Registered User
no team (Team NI)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 3,926
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: improvements to demo camera code anyone

Glad to help. Good luck.

Greg McKaskle
Reply With Quote
Reply


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
easyc demo code not working sniggel Programming 5 01-28-2007 03:40 PM
Camera tracking demo in easyC or WPILib BradAMiller Programming 0 01-25-2007 01:01 PM
2007 demo code not working thefro526 Programming 4 01-12-2007 10:43 PM
Labview Demo File for 2006 Camera? JABianchi General Forum 2 09-15-2006 05:23 PM
For anyone who doesn't get the camera code..... Jake M Programming 8 01-16-2006 05:56 PM


All times are GMT -5. The time now is 01:31 PM.

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


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