Go to Post "FIRST is not about getting as little help as possible - In fact, it's the opposite- the goal is have to make you feel obligated to thank as many people as possible for helping you in ways that you didn't really think you needed or even considered that you could use help." - boomergeek [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 27-02-2008, 00:32
Unsung FIRST Hero
Greg Marra Greg Marra is offline
[automate(a) for a in tasks_to_do]
FRC #5507 (Robotic Eagles)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2005
Location: San Francisco, CA
Posts: 2,030
Greg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond repute
[not-FIRST] Camera Image Processing

Hello,

I am working on an unrelated-to-FIRST project at college in which I am doing image processing on tiny robots with cameras. The only thing is, the only image processing I have ever dealt with is the CMUCam, which does all it's processing onboard so it can give you back nice "x1 y1 x2 y2 x_center y_center" values.

Unfortunately, I don't get such pretty data. I get an array of bytes that represents an image in the YUV color space. I want to do some analysis of this image to find a blob of a certain color. I am not entirely sure how to do this and am going to poke around to try and find things smart people who have done this before have written.

Has anyone else worked with this sort of do-it-yourself image processing? Can you point me at any resources? I'd be most grateful!
  #2   Spotlight this post!  
Unread 27-02-2008, 01:47
Eldarion's Avatar
Eldarion Eldarion is offline
Electrical Engineer / Computer Geek
AKA: Eldarion Telcontar
no team (Teamless Orphan)
Team Role: Alumni
 
Join Date: Nov 2005
Rookie Year: 2005
Location: Númenor
Posts: 558
Eldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond reputeEldarion has a reputation beyond repute
Send a message via AIM to Eldarion Send a message via Yahoo to Eldarion
Re: [not-FIRST] Camera Image Processing

Well, to do the task that you are describing should be pretty simple:
1. Run the entire image through a color thresholding algorithm--replace pixels that are "close" to your desired color with a 1, and everything else with a 0.
2. If you want to do this the way the CMUCam does, scan through the resulting binary array, and every time a 1 is encountered add its X and Y coordinates (your scan variables) to separate large registers. Also increment another register that will hold the total number of 1s encountered. Divide X and Y by that register, and you will have the center and size of the blob in a very similar manner to the CMUCam.

If you need to isolate different blobs of the same color, this becomes more involved. You can take a look at my FALCON system's algorithms for one complicated but quite effective way to do it.

Hope this helps some!

Eldarion
__________________
CMUCam not working? Tracks sporadically? Try this instead: http://www.falconir.com!
PM me for more information if you are interested (it's open source!).

Want the FIRST Email blasts? See here: http://www.chiefdelphi.com/forums/sh...ad.php?t=50809

"The harder the conflict, the more glorious the triumph. What we obtain too cheaply, we esteem too lightly; it is dearness only that gives everything its value."
-- Thomas Paine

If it's falling apart it's a mechanical problem. If it's spewing smoke it's a electrical problem.
If it's rampaging around destroying things it's a programming problem.

"All technology is run on 'Magic Smoke' contained within the device. As everyone knows, whenever the magic smoke is released, the device ceases to function."
-- Anonymous

I currently speak: English, some German, Verilog, x86 and 8051 Assembler, C, C++, VB, VB.NET, ASP, PHP, HTML, UNIX and SQL
  #3   Spotlight this post!  
Unread 27-02-2008, 02:48
fledman fledman is offline
Registered User
AKA: David Feldman
FRC #1525
Team Role: College Student
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Deerfield, IL
Posts: 8
fledman is an unknown quantity at this point
Re: [not-FIRST] Camera Image Processing

There are a lot of vision algorithms, and picking the right one isn't straightforward. It really depends on what your source data is and what you are trying to get out of it, as well as your performance limitations. If you are trying to find colored blobs without definite shapes, some things that I can think of off the top of my hand are expanding shapes (such as rectangles or circles), fitting shapes, random sampling algorithms, and weighted averages / other statistical calculations. If shape does matter, it gets more complicated. Basically, the best way to start learning about this sort of thing is just to mess around and to see what works. Reading papers is also useful for researching algorithms / strategies if you can get through the math (at least the important bits).

Here are a few pdfs from a robot competition. The code samples inside are in java, so you can ignore the topics on java-specific features (i.e. how it handles binary manipulations or performance of various ways to access image data). But the ideas are mostly pretty general (they don't go into that much depth) so it could be a good jumping off point.

http://web.mit.edu/6.186/2006/lectures/Vision.pdf
http://web.mit.edu/6.186/2005/doc/morevision.pdf
http://web.mit.edu/6.186/2007/tutori...geTutorial.pdf

To repeat, the pdfs won't help you with implementation, but they may spark some ideas / give a basic overview of a few concepts.
  #4   Spotlight this post!  
Unread 27-02-2008, 14:04
Scott L.'s Avatar
Scott L. Scott L. is offline
Registered User
FRC #0222 (Tigertrons)
Team Role: Engineer
 
Join Date: Sep 2003
Rookie Year: 1998
Location: Tunkhannock PA
Posts: 290
Scott L. is just really niceScott L. is just really niceScott L. is just really niceScott L. is just really niceScott L. is just really nice
Send a message via AIM to Scott L.
Lightbulb Re: [not-FIRST] Camera Image Processing

National Instruments has "Vision" software. It was used during the Aim High season to count the balls in the lower goals. The cameras used were unibrain fire-I firewire cameras.
__________________
You can do anything, if you put your mind to it!!!
http://asp.shinraikon.com
  #5   Spotlight this post!  
Unread 27-02-2008, 14:26
JimWright949's Avatar
JimWright949 JimWright949 is offline
The Owen Day of Seattle
AKA: Jim Wright
FRC #4542 (Titanium Talons)
Team Role: Mentor
 
Join Date: Sep 2003
Rookie Year: 2003
Location: Redmond, WA
Posts: 94
JimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to behold
Re: [not-FIRST] Camera Image Processing

Greg,

The Library that I use for my projects is the Intel OpenCV library. It's an open sourceish type of library. You can find it here:
http://www.intel.com/technology/comp...encv/index.htm

Unfortuantly, all my good sample code is at home and I'm going to be leaving for the Portland regional after work. When I get home on Sunday I will try to post a few samples of what you can do with this library.

-Jim
  #6   Spotlight this post!  
Unread 27-02-2008, 21:10
Salik Syed Salik Syed is offline
Registered User
FRC #0701 (RoboVikes)
Team Role: Alumni
 
Join Date: Jan 2003
Rookie Year: 2001
Location: Stanford CA.
Posts: 514
Salik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud of
Send a message via AIM to Salik Syed
Re: [not-FIRST] Camera Image Processing

I don't have much experience with this but as far as centroid tracking goes, I would guess that it can probably be done pretty easily since there is a lot of coherency from image to image, so you can with a fair amount of confidence start at the centroid of the previous frame then expand out in all directions.

You may be able to use this algorithm:
Phase Correlation
it involves taking the FFT of the image then doing some fancy stuff with it. basically if you run it from frame to frame it will exploit the coherency to very quickly tell you how the centroid has shifted
__________________
Team 701
  #7   Spotlight this post!  
Unread 29-02-2008, 18:44
lynca's Avatar
lynca lynca is offline
Andrew Lynch
FRC #2587 (DiscoBots)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2001
Location: Houston, TX
Posts: 1,611
lynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond reputelynca has a reputation beyond repute
Send a message via AIM to lynca
Re: [not-FIRST] Camera Image Processing

Quote:
Originally Posted by JimWright949 View Post
Greg,

The Library that I use for my projects is the Intel OpenCV library. It's an open sourceish type of library. You can find it here:
http://www.intel.com/technology/comp...encv/index.htm

Unfortuantly, all my good sample code is at home and I'm going to be leaving for the Portland regional after work. When I get home on Sunday I will try to post a few samples of what you can do with this library.

-Jim
OpenCV is the standard choice for most hobby robotics projects. OpenCV requires knowledge of C or C++. If you want more links on OpenCV, I can give a few of the CV functions I use commonly to find blobs. If you don't know C, and you have time to post process the image, I would suggest using Matlab's image processing toolbox (it works well with webcams). If you have a IEEE 1394 compliant camera(not a webcam), then the Labview vision toolbox would also be useful for realtime and post-processing.
__________________
History: 624 - Cryptonite --> 118 - Robonauts --> 2158 - AusTIN CANS --> 2587 DiscoBots
Bio: Andrew Lynch "How I Work" ---- LinkedIn , Facebook, Twitter
  #8   Spotlight this post!  
Unread 29-02-2008, 23:13
Unsung FIRST Hero
Greg Marra Greg Marra is offline
[automate(a) for a in tasks_to_do]
FRC #5507 (Robotic Eagles)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2005
Location: San Francisco, CA
Posts: 2,030
Greg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond repute
Re: [not-FIRST] Camera Image Processing

Quote:
Originally Posted by lynca View Post
OpenCV is the standard choice for most hobby robotics projects. OpenCV requires knowledge of C or C++. If you want more links on OpenCV, I can give a few of the CV functions I use commonly to find blobs. If you don't know C, and you have time to post process the image, I would suggest using Matlab's image processing toolbox (it works well with webcams). If you have a IEEE 1394 compliant camera(not a webcam), then the Labview vision toolbox would also be useful for realtime and post-processing.
I am, unfortunately, programming for an embedded controller (on a Surveyor SRV1) in an unheard of programming language (occam pi). This library seems to be for PCs, so won't work.

I am investigating some other stuff, thanks for all the suggestions so far! If anyone else knows any good resources please pass them on!
  #9   Spotlight this post!  
Unread 02-03-2008, 17:45
comphappy comphappy is offline
Registered User
AKA: Brennan Ashton
FRC #2605 (A2D_16)
Team Role: Leadership
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Bellingham, WA
Posts: 157
comphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to beholdcomphappy is a splendid one to behold
Send a message via AIM to comphappy
Re: [not-FIRST] Camera Image Processing

You might want to play with the PPM format, it is really easy to work with all the data is stored in ASCII text or similar. Then you can look into using a compression algorithm.
http://en.wikipedia.org/wiki/Netpbm_format

When I was working on an embedded system image processing project, I used the CIMG library, it is really easy to use, and allows you easily display the images in a gui with a lot of feed back with about 10 lines of code. If you want some sample code from my project, ask.
http://cimg.sourceforge.net/
__________________
A2D Solving the Imaginary Error Function...
  #10   Spotlight this post!  
Unread 02-03-2008, 18:46
activemx's Avatar
activemx activemx is offline
A M X
AKA: Akshay Dodeja
no team
Team Role: College Student
 
Join Date: Jan 2002
Rookie Year: 2000
Location: Portland, Oregon
Posts: 312
activemx is a glorious beacon of lightactivemx is a glorious beacon of lightactivemx is a glorious beacon of lightactivemx is a glorious beacon of lightactivemx is a glorious beacon of light
Send a message via AIM to activemx Send a message via Yahoo to activemx
Re: [not-FIRST] Camera Image Processing

Quote:
Originally Posted by JimWright949 View Post
Greg,

The Library that I use for my projects is the Intel OpenCV library. It's an open sourceish type of library. You can find it here:
http://www.intel.com/technology/comp...encv/index.htm

Unfortuantly, all my good sample code is at home and I'm going to be leaving for the Portland regional after work. When I get home on Sunday I will try to post a few samples of what you can do with this library.

-Jim
This is what I would do.
__________________
2005 - Present - FIRST Volunteer(Inspector, Ref, Judge)
2000-2004 MVRT 115
  #11   Spotlight this post!  
Unread 11-03-2008, 20:57
David55 David55 is offline
Registered User
AKA: David Hillman
FRC #1577 (Steampunk) & FRC #125 (NUTRONS)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Raanana, Israel / Boston, MA
Posts: 279
David55 is a splendid one to beholdDavid55 is a splendid one to beholdDavid55 is a splendid one to beholdDavid55 is a splendid one to beholdDavid55 is a splendid one to beholdDavid55 is a splendid one to behold
Re: [not-FIRST] Camera Image Processing

I would also recommend OpenCV. However, if you looked at it and it does not fit your needs (they are for PC's as you said), you can write your own functions for doing it.

Please correct me if I'm wrong (I have never dealt with color tracking), but I would take this approach:
Find the YUV values (or range of values) that correspond to your target color.
Locate the pixels that are in that range (assuming your array indices correspond to image pixels), cancel out all the pixels and small blobs that are alone (representing false positives) and you are left with your blob.
  #12   Spotlight this post!  
Unread 11-03-2008, 21:10
tdlrali tdlrali is offline
Registered User
FRC #0469 (Las Guerrillas)
Team Role: Programmer
 
Join Date: Sep 2006
Rookie Year: 2006
Location: MI
Posts: 377
tdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud of
Re: [not-FIRST] Camera Image Processing

Often rectangle-fitting is adequate; start the rectangle on a pixel that you know to be part of the object (due to color), and expand the rectangle in all directions until the colors are outside the threshold.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Processing on mouth ROI tommy_chai Programming 0 20-11-2007 08:32
thoughts about image processing 3dude_2231 Technical Discussion 5 12-11-2007 13:26
Critique my image processing program... Salik Syed Programming 13 29-06-2006 16:57
Camera not working st1nkm4n Programming 7 02-02-2006 08:22
Camera not found! SpeakerSilenced Programming 0 21-02-2005 12:54


All times are GMT -5. The time now is 16:46.

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