Go to Post Long Live FIRST! - IndySam [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-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 15-01-2009, 16:01
jacobhurwitz jacobhurwitz is offline
Registered User
FRC #0449 (Blair Robot Project)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryland
Posts: 45
jacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura about
449's code for tracking two colors

FIRST recently posted some code to track two colors (http://joule.ni.com/nidu/cds/view/p/lang/en/id/1215). However, our team had already written similar code, and after comparing the two, we think that our team's code is easier to understand and perhaps even faster. The main difference (as far as I can tell) is that FIRST's code will move the camera to track the object while our code only returns a position.

In the spirit of gracious professionalism, we decided to make our team's code available to everyone. You're welcome to use this code and/or modify to suit your own team's needs. If you find anything wrong with our code*, please let us know as well. Also, you'll need to change the color value ranges and minimum area and distances.

*If you look at the image outputs, you might see that they "flicker" occasionally. We think this is only a problem with the image output because the numerical output parameters look fine.

EDIT: fixed parenthesis in link
Attached Files
File Type: zip LocateTwoColoredObjects 449 for Chief Delphi 01-15-09.zip (86.2 KB, 217 views)

Last edited by jacobhurwitz : 16-01-2009 at 10:01.
Reply With Quote
  #2   Spotlight this post!  
Unread 15-01-2009, 17:41
dipmeinaluminum's Avatar
dipmeinaluminum dipmeinaluminum is offline
Michael Vilarelle Mentor
AKA: (Former Mentor 354 Westinghouse Pirates)
FRC #0333 (The Megalodons)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Brooklyn
Posts: 140
dipmeinaluminum is a splendid one to beholddipmeinaluminum is a splendid one to beholddipmeinaluminum is a splendid one to beholddipmeinaluminum is a splendid one to beholddipmeinaluminum is a splendid one to beholddipmeinaluminum is a splendid one to beholddipmeinaluminum is a splendid one to behold
Re: 449's code for tracking two colors

wow, how can i thank you, im loading it into my program now. : ) !!!!!
__________________

Team#333 (2013-Present)
Team#354 (2000-2013)
https://www.youtube.com/watch?v=Bu5-NvMUQ-Y
Reply With Quote
  #3   Spotlight this post!  
Unread 15-01-2009, 18:51
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,748
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: 449's code for tracking two colors

The posted code looks like it thresholds the entire image two times, one for green, one for pink. Then it compares the position of the largest pink and largest green. This approach will work under plenty of conditions, but there reasons that the NI code is more complex.

First, I'll explain the NI code, then try to detail the situations where they will give different results.

The NI code thresholds the entire image once, using pink by default, then goes through the particles large-to-small, looking nearby for a matching green.

How do they differ? Performance is the first difference. If the whole image is 320x240, that results in 76,800 pixels to look at. Doing this again for the second color doubles the work to 153,600. Not bad, but let's count the NI compares. The first color takes 76,800, then the largest particle is used to subset two image areas to threshold them. Even when really close to the object, this will usually be less than 80x80 each, or 12800 pixels, resulting in 89,600 pixel compares. As the target gets further away, the pixel count goes to 76,800 when no particles are found. I don't really think you will run could build a scene that would do 2x pixel compares. Assuming the image copies are quick, the more complicated algorithm actually should run faster.

How else do they differ? Let's pretend that the image captured by the camera is pretty noisy -- robot bumpers, colored robots, t-shirts, hats, mohawks, etc. Because of lighting variation, the color threshold is intentionally set to be pretty tolerant. This means that something pink may be close enough to the pink of the target to pass the threshold. In fact, something orange may pass as well, along with some stuff colored red. This means that the color threshold will often have objects in it other than the target. When one of those particles is actually larger than the target, it isn't sufficient to look at only the largest particle. It is good to keep going down the list looking at each particle to see if it has the green nearby to qualify it as a target.

I hope this examination made sense. I'd encourage you to verify the differences for yourself. You may very well come up something even better, and at the very least you will learn how they work, and when they may fail, so you can use them to your advantage.

Greg McKaskle
Reply With Quote
  #4   Spotlight this post!  
Unread 15-01-2009, 20:28
Tanner's Avatar
Tanner Tanner is offline
Registered User
FRC #1261 (Roblions)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Suwanee, GA
Posts: 311
Tanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to behold
Re: 449's code for tracking two colors

Where exactly did you find the code released by FIRST to track two colors? The link in your post does not work anymore.

Thanks
-Tanner
Reply With Quote
  #5   Spotlight this post!  
Unread 15-01-2009, 21:19
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,748
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: 449's code for tracking two colors

The link above has a parenthesis on the end. It works fine without that.

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
Two Color Tracking Demo Bharat Nain Programming 43 25-01-2009 18:58
Using kevin's code for driving and camera tracking razzoc Programming 3 18-02-2007 08:50
Tracking two lights Render Programming 5 29-01-2007 18:14
tracking two tetras? Anton Programming 5 09-02-2005 15:02
Tracking Different Colors russell Programming 2 06-02-2005 22:40


All times are GMT -5. The time now is 08:59.

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