Escolar Documentos
Profissional Documentos
Cultura Documentos
CENTRO DE INVESTIGACION
Agosto 2007
,
J.B. Hayet
1 / 64
Outline
1
OpenCV y IPP
Tricks
,
J.B. Hayet
2 / 64
Procesamiento de im
agenes con OpenCV
,
J.B. Hayet
3 / 64
Image Processing
Gradients, Edges and Corners
Sampling, Interpolation and Geometrical Transforms
Morphological Operations
Filters and Color Conversion
Pyramids and the Applications
Image Segmentation, Connected Components and Contour
Retrieval
Image and Contour Moments
Special Image Transforms
Histograms
Matching
,
J.B. Hayet
4 / 64
Structural Analysis
Contour Processing
Computational Geometry
Planar Subdivisions
,
J.B. Hayet
5 / 64
,
J.B. Hayet
6 / 64
Pattern Recognition
Object Detection
,
J.B. Hayet
7 / 64
Camera Calibration
Pose Estimation
Epipolar Geometry
,
J.B. Hayet
8 / 64
Outline
1
OpenCV y IPP
Tricks
,
J.B. Hayet
9 / 64
Conversi
on entre espacios de color
,
J.B. Hayet
10 / 64
Umbral
Umbral :
double c v T h r e s h o l d ( const CvArr s r c ,
CvArr d s t , double t h r e s h o l d ,
double m a x v a l , i n t t h r e s h t y p e ) ;
,
J.B. Hayet
11 / 64
Filtros
v o i d c v F i l t e r 2 D ( const CvArr s r c , CvArr d s t ,
const CvMat k e r n e l ,
C v P o i n t a n c h o r=c v P o i n t ( 1 , 1));
Ejemplo de uso:
CvMat k e r n e l = c v C r e a t e M a t ( 1 1 , 1 1 , CV 32F ) ;
cvSet ( kernel ,
c v S c a l a r ( 1 . / ( k e r n e l >rows k e r n e l >c o l s ) ) ) ;
c v F i l t e r 2 D (A , B , k e r n e l ,
c v P o i n t ( k e r n e l >c o l s / 2 ,
k e r n e l >rows / 2 ) ) ;
,
J.B. Hayet
12 / 64
Filtros : smoothing
,
J.B. Hayet
13 / 64
Filtros : smoothing
CV BLUR NO SCALE
CV BLUR ( s i m p l e b l u r )
CV GAUSSIAN ( g a u s s i a n b l u r )
CV MEDIAN ( median b l u r )
CV BILATERAL
,
J.B. Hayet
14 / 64
Derivadas y bordos
Sobel, Canny
v o i d c v S o b e l ( const CvArr s r c , CvArr d s t ,
int xorder , int yorder ,
i n t a p e r t u r e s i z e =3);
v o i d cvCanny ( const CvArr image , CvArr e d g e s ,
double t h r e s h o l d 1 ,
double t h r e s h o l d 2 , i n t a p e r t u r e s i z e =3);
,
J.B. Hayet
15 / 64
Derivadas y bordos
,
J.B. Hayet
16 / 64
Derivadas y bordos
,
J.B. Hayet
17 / 64
Laplaciano
,
J.B. Hayet
18 / 64
Im
agenes integrales
,
J.B. Hayet
19 / 64
Pir
amides gausianas
Up-sampling :
v o i d cvPyrUp ( const CvArr s r c , CvArr d s t ,
i n t f i l t e r =CV GAUSSIAN 5x5 ) ;
,
J.B. Hayet
20 / 64
Pir
amides gausianas
,
J.B. Hayet
21 / 64
Morfologa matem
atica
Flexibilidad en la definicion del elemento estructurante
IplConvKernel cvCreateStructuringElementEx (
i n t c o l s , i n t rows ,
i n t anchx , i n t anchy ,
i n t shape ,
i n t v a l u e s=NULL ) ;
c v R e l e a s e S t r u c t u r i n g E l e m e n t ( I p l C o n v K e r n e l e l ) ;
,
J.B. Hayet
22 / 64
Morfologa matem
atica
Formas soportadas
CV SHAPE RECT
CV SHAPE CROSS
CV SHAPE ELLIPSE
CV SHAPE CUSTOM
,
J.B. Hayet
23 / 64
Morfologa matem
atica
Operadores basicos :
v o i d c v E r o d e ( const CvArr s r c , CvArr d s t ,
I p l C o n v K e r n e l e l e m e n t=NULL , i n t i t e r a t i o n s =1);
v o i d c v D i l a t e ( const CvArr s r c , CvArr d s t ,
I p l C o n v K e r n e l e l e m e n t=NULL , i n t i t e r a t i o n s =1);
,
J.B. Hayet
24 / 64
Morfologa matem
atica
,
J.B. Hayet
25 / 64
Puntos de inter
es
Todos los metodos implementados son basados en la matriz de
autocorrelacion :
v o i d c v C o r n e r M i n E i g e n V a l ( const CvArr img , CvArr e i g ,
i n t b l o c k s i z e , i n t a p s i z e =3);
v o i d c v C o r n e r H a r r i s ( const CvArr image , CvArr d s t ,
i n t b l o c k s i z e , i n t a p s i z e =3,
double k =0.04 ) ;
v o i d c v F i n d C o r n e r S u b P i x ( const CvArr img ,
CvPoint2D32f c o r n e r s ,
i n t count ,
C v S i z e win , C v S i z e z e r o z o n e ,
CvTermCriteria c r i t e r i a ) ;
,
J.B. Hayet
26 / 64
LK tracking
,
J.B. Hayet
27 / 64
LK tracking
,
J.B. Hayet
28 / 64
Histogramas
t y p e d e f s t r u c t CvHis t ogram {
int
type ;
CvArr b i n s ;
float
t h r e s h [ CV MAX DIM ] [ 2 ] ; / u n i f o r m h i s t . /
f l o a t t h r e s h 2 ; / nonu n i f o r m h i s t . /
CvMatND mat ; / m a t r i x h e a d e r f o r a r r a y h i s t . /
} Cv His togram ;
,
J.B. Hayet
29 / 64
Histogramas
30 / 64
Histogramas : ejemplo
,
J.B. Hayet
31 / 64
Histogramas : comparaci
on
Varias metricas para histogramas :
double c v C o m p a r e H i s t ( const Cv His t ogram h i s t 1 ,
const Cv His t ogram h i s t 2 ,
i n t method ) ;
CV COMP CORREL
CV COMP CHISQR
CV COMP INTERSECT
CV COMP BHATTACHARYYA
,
J.B. Hayet
32 / 64
Transformada de Hough
Metodo clasico de acumulacion para la deteccion de objetos
parametrizados :
CvSeq c v H o u g h L i n e s 2 ( CvArr img , v o i d l i n e s t o r a g e ,
i n t method ,
double rho , double t h e t a ,
int thresh ,
double p a r 1 =0, double p a r 2 =0);
CvSeq c v H o u g h C i r c l e s ( CvArr img , v o i d c i r c s t o r a g e ,
i n t method ,
double dp , double m i n d i s t ,
double p a r 1 =100 ,
double p a r 2 =100 ,
i n t m i n r a d i u s =0,
i n t m a x r a d i u s =0);
,
J.B. Hayet
33 / 64
,
J.B. Hayet
34 / 64
,
J.B. Hayet
35 / 64
Detecci
on de caras
Un ejemplo que viene por default con OpenCV:
,
J.B. Hayet
36 / 64
,
J.B. Hayet
37 / 64
,
J.B. Hayet
38 / 64
Outline
1
OpenCV y IPP
Tricks
,
J.B. Hayet
39 / 64
Calibraci
on
,
J.B. Hayet
40 / 64
Calibraci
on
Funcion de calibracion :
v o i d c v C a l i b r a t e C a m e r a 2 ( const CvMat o b j e c t p o i n t s ,
const CvMat i m a g e p o i n t s ,
const CvMat p o i n t c o u n t s ,
CvSize image size ,
CvMat i n t r i n s i c m a t r i x ,
CvMat d i s t o r t i o n c o e f f s ,
CvMat r o t v e c t o r s=NULL ,
CvMat t r a n s v e c t o r s=NULL ,
i n t f l a g s =0 ) ;
,
J.B. Hayet
41 / 64
Calibraci
on
,
J.B. Hayet
42 / 64
Calibraci
on: distorsi
on radial y tangencial
Correccion de la distorsion :
v o i d c v U n d i s t o r t 2 ( const CvArr s r c , CvArr d s t ,
const CvMat i n t r i n s i c m a t r i x ,
const CvMat d i s t o r t i o n c o e f f s ) ;
,
J.B. Hayet
43 / 64
Calibraci
on : distorsi
on radial y tangencial
,
J.B. Hayet
44 / 64
,
J.B. Hayet
45 / 64
Estimaci
on de la pose (c
amara calibrada)
v o i d cvPOSIT ( CvPOSITObject p o s i t o b j e c t ,
CvPoint2D32f i m a g e p o i n t s ,
double f o c a l l e n g t h ,
CvTermCriteria c r i t e r i a ,
CvMatr32f r o t a t i o n m a t r i x ,
CvVect32f t r a n s l a t i o n v e c t o r ) ;
,
J.B. Hayet
46 / 64
Geometra epipolar
,
J.B. Hayet
47 / 64
OpenCV y IPP
Outline
1
OpenCV y IPP
Tricks
,
J.B. Hayet
48 / 64
OpenCV y IPP
IPP
,
J.B. Hayet
49 / 64
OpenCV y IPP
IPP : d
onde esta la magia ?
,
J.B. Hayet
50 / 64
OpenCV y IPP
IPP: Scope
Video encoding/decoding
Procesamiento
de
imagenes
Vectores y matrices
Procesamiento del hablar
Audio decoding/encoding
Vision
JPEG/JPEG2000
Rendido
Compresion de datos
Procesamiento
se
nal
Criptografia
...
de
,
J.B. Hayet
51 / 64
OpenCV y IPP
Ejemplo
I p p S t a t u s ippiRGBToGray <mod>(
const Ipp <d a t a t y p e > pSrc , i n t s r c S t e p ,
Ipp <d a t a t y p e > pDst , i n t d s t S t e p , I p p i S i z e r o i S i z e ) ;
Valores de mod:
8u C3C1R 16 u C3C1R 16 s C3C1R 32 f C3C1R
8u AC4C1R 16 u AC4C1R 16 s AC4C1R 32 f AC4C1R
,
J.B. Hayet
52 / 64
OpenCV y IPP
,
J.B. Hayet
53 / 64
OpenCV y IPP
IPP y OpenCV
,
J.B. Hayet
54 / 64
OpenCV y IPP
IPP y OpenCV
Verificar que s se usa IPP:
const char p l u g i n i n f o= 0 ;
c v G e t M o d u l e I n f o (0 , 0 ,& p l u g i n i n f o ) ;
i p p i s u s e d= ( p l u g i n i n f o != 0 ) &&
s t r s t r ( p l u g i n i n f o , ipp )!=0;
. . . cvUseOptimized ( 1 ) ;
,
J.B. Hayet
55 / 64
Outline
1
OpenCV y IPP
Tricks
,
J.B. Hayet
56 / 64
Python y OpenCV
,
J.B. Hayet
57 / 64
Python y OpenCV
No hay IplImage aca, solo CvMat
Iteratores
x = c v C r e a t e M a t (m, n , t y p e )
f o r row i n x :
# row i s same a s t h a t r e t u r n e d by cvGetRow
o:
for col in x . colrange ( ) :
# c o l i s same a s t h a t r e t u r n e d by c v G e t C o l
,
J.B. Hayet
58 / 64
Python y OpenCV
,
J.B. Hayet
59 / 64
Python y OpenCV
,
J.B. Hayet
60 / 64
Tricks
Outline
1
OpenCV y IPP
Tricks
,
J.B. Hayet
61 / 64
Tricks
Uso de la memoria
,
J.B. Hayet
62 / 64
Tricks
,
J.B. Hayet
63 / 64
Tricks
Alineaci
on de datos
,
J.B. Hayet
64 / 64