20.07.2013 Views

OpenCV pdf

OpenCV pdf

OpenCV pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

OPENCV


Mac Ox alternative to opencv installation<br />

According to:<br />

http://opencv.willowgarage.com/wiki/Mac_OS_X_<strong>OpenCV</strong>_Port<br />

(Method 2)<br />

If you do not have macports, install it<br />

http://www.macports.org/install.php<br />

On a new shell, install cmake<br />

sudo port install cmake<br />

Check out the openCV sourceCode<br />

svn co https://code.ros.org/svn/opencv/trunk/opencv<br />

From the opencv directory run Cmake<br />

sudo cmake -G "Unix Makefiles"<br />

sudo make -j8<br />

sudo make install


Compile the application as:<br />

gcc -o Ej2C ejemplo2ymedio.c -I/usr/local/include/opencv<br />

-L/usr/local/lib -lopencv_core -lopencv_highgui -lopencv_ml<br />

-lopencv_video -lopencv_imgproc -lopencv_calib3d


Windows installation on VS 2008<br />

Download the 2.1 installer<br />

http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.1/<strong>OpenCV</strong>-2.1.0win32-vs2008.exe/download<br />

Restart the computer<br />

Follow the instructions on;<br />

http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2010


Library structure<br />

From: Learning <strong>OpenCV</strong>, Gary Bradsky & Adrian Kaebler O’Reilly 2008


Example 1. camera capture and GUI<br />

Example 2. Simple image manipulation<br />

Example 3. RGB splitting<br />

Example 4. Using masks<br />

Example 5. Edges<br />

Example 6. Pseudo color


Example 7 Non linear mapping<br />

(x,y)<br />

Example:<br />

u<br />

v<br />

Input<br />

= x cos<br />

=<br />

y<br />

( y)<br />

Inverse Transform<br />

(u,v)<br />

Output


Example 8 Histogram Backpropagation<br />

x 1 0<br />

4<br />

4<br />

3 . 5<br />

3<br />

2 . 5<br />

2<br />

1 . 5<br />

1<br />

0 . 5<br />

0<br />

0 0 . 1 0 . 2 0 . 3 0 . 4 0 . 5 0 . 6 0 . 7 0 . 8 0 . 9 1


Ex9 Cam-shift color-Tracking<br />

The mean-shift Algorithm:<br />

7 0 0 0<br />

6 0 0 0<br />

5 0 0 0<br />

4 0 0 0<br />

3 0 0 0<br />

2 0 0 0<br />

1 0 0 0<br />

7 0 0 0<br />

6 0 0 0<br />

5 0 0 0<br />

4 0 0 0<br />

3 0 0 0<br />

2 0 0 0<br />

1 0 0 0<br />

0<br />

0<br />

0 5 0 1 0 0 15 0 2 0 0 2 5 0<br />

0 5 0 1 0 0 1 5 0 2 0 0 2 5 0<br />

1. Define a window<br />

2.find the mass center


7 0 0 0<br />

6 0 0 0<br />

5 0 0 0<br />

4 0 0 0<br />

3 0 0 0<br />

2 0 0 0<br />

1 0 0 0<br />

7 000<br />

6 000<br />

5 000<br />

4 000<br />

3 000<br />

2 000<br />

1 000<br />

0<br />

0<br />

0 5 0 10 0 15 0 200 2 50<br />

0 5 0 1 0 0 1 5 0 2 0 0 2 5 0<br />

3. Re-center the windows<br />

repeat 2-3 to convergence


Cam-shift Algorithm<br />

1. Find the object histogram.<br />

2. Calculate the histogram backprojection on the search<br />

window.<br />

3. Iterate the mean-shift algorithm to find the mode on x and<br />

y dimensions.<br />

4. Update the center and window dimensions.<br />

5. Go to step 2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!