Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   [not-FIRST] Camera Image Processing (http://www.chiefdelphi.com/forums/showthread.php?t=65176)

Greg Marra 27-02-2008 00:32

[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!

Eldarion 27-02-2008 01:47

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

fledman 27-02-2008 02:48

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.

Scott L. 27-02-2008 14:04

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.

JimWright949 27-02-2008 14:26

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

Salik Syed 27-02-2008 21:10

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

lynca 29-02-2008 18:44

Re: [not-FIRST] Camera Image Processing
 
Quote:

Originally Posted by JimWright949 (Post 708320)
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.

Greg Marra 29-02-2008 23:13

Re: [not-FIRST] Camera Image Processing
 
Quote:

Originally Posted by lynca (Post 710031)
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! :)

comphappy 02-03-2008 17:45

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/

activemx 02-03-2008 18:46

Re: [not-FIRST] Camera Image Processing
 
Quote:

Originally Posted by JimWright949 (Post 708320)
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.

David55 11-03-2008 20:57

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.

tdlrali 11-03-2008 21:10

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.


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

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