You are on page 1of 137

CS Club 17-18 2011

OpenCV

http://pixdaus.com/pics/1244922167d3Z4fjf.jpg


www.uralvision.blogspot.com

perevalovds@gmail.com

1.
2.
3. OpenCV
4. OpenCV -
5.

6.

7.


-
-


:
- ,
- OpenCV,
- ,

.
:


:
1) ,
(-) . ,
1-10 .
2)
.
:
1) GPU.
2) .


- ,

.


- , OpenCV,
.


- , ,
,

( ) .

1.

-
- 1-
- 2-
-
-


( )


, .

http://the-gadgeteer.com/wp-content/uploads/2009/12/
mr-robot-head-game.jpg


,
,
. ...
,

. ...

http://www.spectec.net.nz/pictures/cctv%20pic.jpg


(
) .
,
.
, , ,
.
.

http://sobiratelzvezd.ru/wallpapers/wikimedia_23.jpg



- ,

- ,
- ,
- ,
- .

1-


- , "".

:
- , ,
- 3- - 3- .


, , -
:
1.
2.
3.
4.
5.


1.

http://rkc.oblcit.ru/system/files/images/%D0%9F%D1%80%D0%B8%D1%80%D0%BE%D0%B4%D0%B013.preview.jpg
http://imaging.geocomm.com/gallery/san_francisco_IOD032102.jpg


2.

http://lh6.ggpht.com/_Wy2U3qKMO8k/SSyB6BTdg8I/AAAAAAAACd8/Iai_3QZIjrI/Australia+5+dollars+B+se.jpg
http://i367.photobucket.com/albums/oo117/syquest/acrylic_no_filter.jpg


3.
:

http://ess.ru/publications/2_2003/sedov/ris6.jpg


4.
:

http://cdn.wn.com/pd/b1/3a/abd9ebc81d9a3be0ba7c4a3dfc28_grande.jpg


5.

http://opencv.willowgarage.com/documentation/c/
_images/disparity.png

http://www.youtube.com/watch?v=pk_cQVjqFZ4

1-


- , "".

,
2D-

2-

-
.

http://www.tyvek.ru/construction/images/structure.jpg

,
2D-

,
2D-
1.
, ,
.
- , , ,
(, , ...)
2.
,
- , .

3.
- .
, ,
.
1. 2.


- ""
.



,
.

http://armi.kaist.ac.kr/korean/UserFiles/File/MMPC.JPG


-
.

http://www.merl.com/projects/images/particle.jpg


-
, MIT, .

http://www.csail.mit.edu/videoarchive/research/gv/hand-tracking


(
).

http://www.edhv.nl/edhv/wp-content/uploads/2009/12/aug_Picture-10_no-border-450x337.jpg
http://jamiedubs.com/fuckflickr/data/web/ar-marker-BchThin_0036.png

.
( - , -
,
).

http://www.promrds.com/chapter9/Images/NewMaze.gif

2.

-
-



.
:
1.
2.
3.

4.


, .

320 x 240

640 x 480

1280 x 1024





1:
1:
1:
1.56
0.97
3.13
30 :
30 :
30 :
6.6
26.4
112.5
http://www.mtlru.com/images/klubnik1.jpg


, .

30 /

60 /

: :
33
16

http://www.youtube.com/watch?v=7iEvQIvbn8o

150 /
:
6

(
)


-,


( )


-
- -
- Firewire-
-
- ""

(USB-)
( IEEE-1394)
(IP-)
(Smart cameras)

,
( ).
(+) ,
(100 )
(+) ,
(-) "", .
(-) "", -
, .
( 2 , 50 /)

- (USB-)

~2000.,
USB-,
, JPEG.
(+)
(+) ,
(-) - JPEG
.
(-) (
)
(-) - USB
2- USB-, PC 2-3 USB .

Firewire- (IEEE-1394)

,
FireWire,
,
.
(+)
(+)
(+)

(-)
(-) ,

(IP-)

,
( )
.
.
(+)
(+)
(+) ,
, ,
..
(+) - ,
(-)
(-)
(-) (2011 )

"" (Smart cameras)


,
.

,

.. .
(+) .
(+) - .
(-) .
(-) ,
.


-
, , -.
+ - (
),
.
- -, ,
, .


Sony PS3 Eye
320 x 240 : 150 FPS
640 x 480 : 60 FPS

:
,
( -)
: 50$.
USB, CCD


Point Grey Flea3
648 x 488 : 120 FPS
:
- ,
- (?)
: 600$.

FL3-FW-03S1C-C
IEEE 1394b, CCD


Microsoft Kinect
640 x 480 : 30 FPS
:
+
: 150$.
( - -,
)
USB, CMOS


Point Grey BumbleBee2
640 x 480 : 48 FPS
:
+
: 2000$.
( - )
IEEE 1394b, CCD

3. OpenCV
- OpenCV
- OpenCV
- Mat
-

OpenCV

"Open Computer Vision Library"



, ,
C/C++.

OpenCV
2000 - -, Intel, C-
2006 - 1.0
2008 - Willow Garage (. )
2009 - 2.0, ++
2010 - 2.2, GPU

OpenCV
1.
, Microsoft Visual C++ 2008 Express Edition
OpenCV 2.1 .
1. VS2008

2.
File - New - Project - Win32 Console Application,
Name Project1, .
3.
Alt+F7 -
Configuration Properties - C/C++ - General - Additional Include Directories,
"C:\Program Files\OpenCV2.1\include\opencv";
Linker - General - Additional Library Directories,
C:\Program Files\OpenCV2.1\lib\

Linker - Input - Additional Dependencies cv210.lib cvaux210.lib cxcore210.lib cxts210.lib highgui210.lib


Release,
cv210d.lib cvaux210d.lib cxcore210d.lib cxts210.lib highgui210d.lib
Debug

OpenCV
2.
1. :
http://www.fitseniors.org/wp-content/uploads/2008/04/green_apple.jpg
C:\green_apple.jpg
2. Project1.cpp:
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
using namespace cv;
int main( int argc, const char** argv )
{
Mat image = imread( "C:\\green_apple.jpg" ); //
imshow( "image", image );
//
waitKey( 0 );
//
return 0;
}
3. F7 - , F5 - .
,
.

OpenCV
3.
main
:
int main( int argc, const char** argv )
{
Mat image = imread( "C:\\green_apple.jpg" );
//image1 0.3*image
Mat image1 = 0.3 * image;
imshow( "image", image );
imshow( "image1", image1 );
waitKey( 0 );
return 0;
}

OpenCV
4.

main :
int main( int argc, const char** argv )
{
Mat image = imread( "C:\\green_apple.jpg" );

//
Rect rect = Rect(100, 100, 200, 200); //
Mat image3;
image( rect ).copyTo( image3 );
// image
imshow( "image3", image3 );
//
image( rect ) *= 2;
imshow( "image changed", image );
waitKey( 0 );
return 0;

Mat
Mat

- OpenCV.

Mat
-
.
.
,
.
1- -
3- - (Red, Green,
Blue).

, OpenCV 2- 4- .

Mat

1)
Mat imageEmpty;
2) w x h , 0..255
(8U "unsigned 8 bit", C1 " "):
int w=150; int h=100;
Mat imageGray( cv::Size( w, h ), CV_8UC1 );

Mat

3) 1-
(32F "float 32 bit"):

Mat imageFloat( cv::Size(w, h), CV_32FC1 );


4) 3- 0..255
:

Mat imageRGB( cv::Size(w, h), CV_8UC3 );

Mat

1.

, OpenCV ,
:
Image imageFloat;
imageGray.convertTo( imageFloat, CV_32FC1, 1.0 / 255.0 );
- OpenCV imageFloat.
, ,
.
2.
( std::vector), ,
.

Mat

( STL shared_ptr, Java


) :
{
Mat A( cv::Size( 100, 100 ), CV_8UC1 );
// , ,
// .
{
Mat B = A;
// ,
// B .
//, B, A.
// , 2.
}
// B , ,
// 1.
}
// A , 0,
// , , .

Mat


Mat B = A;
A B, ,
,
copyTo clone:
image1.copyTo( image2 );
image3 = image1.clone();

Mat

:
1) Mat B = A; ,
,
. Mat
, .
Mat ( std::vector).
, , const Mat & .
2)
copyTo clone.

Mat

OpenCV
. (
), .
, ,
,
OpenCV, , .

Mat

,
- at.
0...255 :
//
int value = imageGray.at<uchar>(y, x);
//
imageGray.at<uchar>(y, x) = 100;
, x y .

Mat


OpenCV ,
, [0,1].
8-
1.0 /
255.0.
(float
unsigned char) convertTo.
.
imageGray.convertTo( imageFloat, CV_32FC1, 1.0 / 255.0 );
!

Mat


cvtColor.
.
, 3- RGB-
:
cvtColor( inputRGB, outputGray, CV_BGR2GRAY );
:
cvtColor( inputGray, outputRGB, CV_GRAY2BGR );

Mat

split .
merge
.
void split ( const Mat& mtx,
vector<Mat>& mv

//
// 1-
//

)
void merge ( const vector<Mat>& mv,

Mat& dst

// 1-
//
//
//

)

, .

Mat

int main( int argc, const char** argv )
{
Mat image = imread( "C:\\green_apple.jpg" );
//
// - channels[0], channels[1], channels[2]
vector<Mat> channels;
split( image, channels );
//
// , - 2, 0.
imshow( "Red", channels[2] );
imshow( "Green", channels[1] );
imshow( "Blue", channels[0] );
waitKey( 0 );
return 0;
}

,
11 x 11

GaussianBlur
.

, .
.

http://www.innocentenglish.com/funny-pics/best-pics/stairs-sidewalk-art.jpg

threshold .

http://www.svi.nl/wikiimg/SeedAndThreshold_02.png

floodFill ,
(x, y), ,
4- 8- .
: - .
,
, .
http://upload.wikimedia.org/wikipedia/commons/thumb/5/5e/Square_4_connectivity.svg/300px-Square_4_connectivity.svg.png
http://tunginobi.spheredev.org/images/flood_fill_ss_01.png

- , .
- Sobel, - Canny.

1. . ,
.
2. . ,
.
http://howto.nicubunu.ro/gears/gears_16.png
http://cvpr.uni-muenster.de/research/rack/index.html

4. OpenCV
-
-
-
-

(Open Audio
Library)

Box2D
2D

(Open Graphics Library)


C

Bullet
3D

1 2

(Open Computing Language)



, ,
GPU.

...


"Creative coding",
,
.

Processing

openFrameworks

Cinder

: Java

Java
.

: C/C++

: C/C++
,
.

1 2 3


" ",

. ,
, .

Max/MSP/Jitter

VVVV

Unity3D


3D.

5.


-
-
- " "
- " "
- C
-
-
-
-

,
,
,
.

http://people.rit.edu/andpph/photofile-misc/strobe-motion-ta-08.jpg

, -
:)

http://zone.ni.com/cms/images/devzone/epd/GeometricMatchingScreenshot.JPG

" "
,
.
,
, .

" "

?
http://fineartamerica.com/images-medium/shadows-in-the-forest-gary-bydlo.jpg

" "
,

.

" "

?
http://flogiston.ru/img/invisible_flounder_fish.jpg

" "
,
,
.

" "

?
http://dangerouswildlife.com/images/zebra-herd.jpg

" " " "



.


- ""
.
- ""
,

.


,
:
- " " ,
- " " - ,
- (, ""),
- ,
"",
- ,
-
.


- GrabCut.
( .)

,
.


:
G = { V, E }.
V,
,
i, j S_i,j
("S" "similarity" - )

http://www.cis.upenn.edu/~jshi/GraphTutorial/




.
.

- .

(..
) - .



,
(,
):

James Malcolm, Yogesh Rathi, Allen Tannenbaum


A Graph Cut Approach to Image Segmentation in Tensor Space
http://jgmalcolm.com/pubs/malcolm_tc.pdf



( ):

Eitan Sharon, Segmentation by Weighted Aggregation, CVPR04


http://www.cis.upenn.edu/~jshi/GraphTutorial/
Tutorial-ImageSegmentationGraph-cut4-Sharon.pdf

Eitan Sharon, Segmentation by Weighted Aggregation, CVPR04


http://www.cis.upenn.edu/~jshi/GraphTutorial/
Tutorial-ImageSegmentationGraph-cut4-Sharon.pdf

Eitan Sharon, Segmentation by Weighted Aggregation, CVPR04


http://www.cis.upenn.edu/~jshi/GraphTutorial/
Tutorial-ImageSegmentationGraph-cut4-Sharon.pdf


(optical flow) -
,
,
.


,
.
( x, y )
( f(x, y), g(x, y) ), :

http://www.ultimategraphics.co.jp/jp/images/stories/ultimate/BCC/optical.jpg


1. ,
.

2.
.
3. ,
.
4.
,
.
, , ..

- 1,
- .

(I) ("" )
, .

(II) ( )
x, y, t.
1. Lucas-Kanade - .
2. Farneback - ,
3. CLG - , OpenCV
4. Lucas-Kanade, " "
5. Horn-Schunk -

(III) ()
min-cut, max-flow,
belief propagation.


OpenCV , Farneback.
(Gunnar Farneb ack "Two-Frame Motion Estimation Based on Polynomial Expansion", Proceedings of the
13th Scandinavian Conference on Image Analysis Pages 363-370 June-July, 2003 )



.
, -
.



, :


- ,
(
).

-
-

http://pages.slc.edu/~ebj/sight_mind/motion/Nakayama/aperture_problem.GIF

1 2
""

,
, ,
,
.
.

perevalovds@gmail.com

6.


- - -
- - HOG

- -
-
.

- -
" ",

http://www710.univ-lyon1.fr/~bouakaz/OpenCV-0.9.5/docs/ref/pics/haarfeatures.png
http://alliance.seas.upenn.edu/~cis520/wiki/uploads/Lectures/viola_jones_first2_small.png

- -

.

- -
- .

- - .
- -
.
, -, ,

.
.

- -
.

- -
.

: 0.158 (158 1000 ) ;


: 0.049 (40 1000 , 58
1000 );
, 84.2%,
4.9%.

- HOG
HOG = Histogram Of Gradients,
.

- HOG
: ,
. .
( SVM).

http://ericbenhaim.free.fr/images/hog_process.png

- HOG

, , .
:

http://www.youtube.com/watch?v=BbL2wWy8KUM

:
-,
,
.

7.

-
- 3D-
-
-


Funky Forest
(2007,
T.Watson)

http://zanyparade.com/v8/projects.php?id=12


Body paint

http://www.youtube.com/watch?v=3T5uhe3KU6s

Yoko Ishii and Hiroshi Homura, Its fire, you can touch it, 2007.

-,
-2011
"
" - 42- -,
, 2 2011 .

www.playbat.net

3-
() ,

, .

http://justinmaier.com/wp-content/uploads/2006/05/ATT5082002.jpg

3-
3 .
,
.

http://www.youtube.com/watch?v=o5tlIIOXMs4


(projection mapping)
,
.

http://www.youtube.com/watch?v=BLNqZ1Nbo7Q



(Architectural Projection Mapping).

http://www.youtube.com/watch?v=BGXcfvWhdDQ


: Markerless
AR
.


:
( , ),
.

2 2
""
( )
, .
,
, .
youtube,
perevalovds@gmail.com.

,

Aleatoric water musical instrument

http://www.youtube.com/watch?v=CZ_KijiwQHE


-
-
-
-



1. ., . .
2. . , . .

OpenCV
1. OpenCV
C++: http://opencv.willowgarage.com/documentation/cpp/index.html
2. G. Bradski, A. Kaehler Learning OpenCV: Computer Vision with the OpenCV Library
- , OpenCV C, C++.

3. OpenCV C++ (, 2010)


http://uralvision.blogspot.com/2010/12/opencv-2010.html

openFrameworks OpenCV,
, 2011.

www.uralvision.blogspot.com


-
-

", , "

art.usu.ru/index.php/confer/229
www.art.usu.ru, www.ncca.ru


", , "
2- , 18:30
: Wearable Computing

10-15 .

, ksenfedorova@gmail.com
( 51, 4 , 413)
- http://www.scribd.com/doc/49078187/Body-As-Interface


", , "

21-22
2-
" "

. ,
, ksenfedorova@gmail.com
ncca.ru, art.usu.ru, usu.ru
www.uralvision.blogspot.com

http://www.ago.net/assets/images/assets/past_exhibitions/2007/steinkamp.jpg


www.playbat.net ( )
- ( . .) www.bframe.ru
5- ( )
gorodaonline.com ( - )

"-" www.mult-on.ru
"" www.anima-tech.ru



perevalovds@gmail.com

www.uralvision.blogspot.com

You might also like