No announcement yet.

Camera Tracking Code Modifications

  • Filter
  • Time
  • Show
Clear All
new posts

  • Camera Tracking Code Modifications

    Hey all,
    We're incorporating the color tracking code into our robot code this year, and we've made a couple of changes we thought everybody else might want to know about. Note: all of this assumes you're searching for pink first. We encountered a separate set of problems with green first and pink proved easier to fix, but that doesn't mean these aren't concerns with searching for green first as well.

    First off, the green fabric we have is much more visible than the pink fabric. Because of this, the code was reporting sporadic results - that is, the code would flicker between being able to locate the target and not being able to locate the target (the mask showing all black). The root of this problem as that the area of the green, especially at larger distances, is greater than 1.5x the area of the pink located, causing the find to fail. To solve this, we changed the coerce in to have 2 as it's upper bound instead of 1.5 (If you're still having problems, you can probe the wire at run time and watch to figure out whatever value to go with). Also I'm a little picky about the use of the CompareSizesv1 VI to decide whether the green is above or below the pink. I prefer a simple greater than or less than. Due to the way CompareSizes works, it picks the size closest to the middle. With our problem, 0-2 pixels was occasionally closer than the larger green area. Using a simple size check to see which area ACTUALLY FOUND green, our tracking code became much more accurate.

    Of course none of this has been tested with field conditions and we haven't yet acquired enough fabric to do more rigorous testing, but from what came in the kit, these changes helped a lot. The following screenshots show how to make these changes if you're still confused, but don't hesitate to ask questions.
    Last edited by jeady; 01-29-2009, 10:49 PM.
    James Eady
    Team 418 Purple Haze
    LASA Robotics, Austin TX

  • #2
    Re: Camera Tracking Code Modifications

    Sorry to hear that it didn't work quite well enough out of the box. I might suggest a different solution to the problem though.

    On the panel of the top example, are the color thresholds. Turn off the gimbal so that you get good feedback, and experiment a bit to find a location and direction where the target doesn't get detected well. Simply comparing different locations and paying attention to the results, you may be able to get a sense for which param to widen to get better results. But normal people open up the Find Color subVI and on that panel is an image display and a Debug HSL button. With the target in a spotty situation, click to turn on the debug and hover the mouse at various pink areas on the target that have dropped out of the mask. It sounds like the edges for you.

    This will give you the current HSL for each pixel, and you can then compare to the thresholds to see if it is the luminance or the saturation, or possibly the hue that needs to change.

    Anyway, by updating the colors, you will get a better pink for your test area and you will not need to worry about modifying the ratios. At that point, you may need to consider whether these changes are cool for a competition field or if your test area is different enough to deserve different constants. By the way, I'm curious what you needed to change and by how much.

    Greg McKaskle