SlideShare una empresa de Scribd logo
1 de 32
Getting Started with OpenCV Vadim Pisarevsky (vadim.pisarevsky@intel.com)
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is OpenCV? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Can you use OpenCV? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],In brief: Sure!
Now the question is: Should you use it?
OpenCV structure CXCORE basic structures and algoritms, XML support, drawing functions CV Image processing and vision algorithms HighGUI GUI, Image and Video I/O We will mostly focus on these two in this presentation
First OpenCV Program 1. #include <cxcore.h> 2. #include <highgui.h> 3. #include <math.h> 4. int main( int argc, char** argv ) { 5.  CvPoint center; 6.  double scale=-3; 7.  IplImage* image = argc==2 ? cvLoadImage(argv[1]) : 0; 8.  if(!image) return -1; 9.  center = cvPoint(image->width/2,image->height/2); 10.  for(int i=0;i<image->height;i++) 11.  for(int j=0;j<image->width;j++) { 12.  double dx=(double)(j-center.x)/center.x; 13.  double dy=(double)(i-center.y)/center.y; 14.  double weight=exp((dx*dx+dy*dy)*scale); 15.  uchar* ptr = &CV_IMAGE_ELEM(image,uchar,i,j*3); 16.  ptr[0] = cvRound(ptr[0]*weight); 17.  ptr[1] = cvRound(ptr[1]*weight); 18.  ptr[2] = cvRound(ptr[2]*weight);  } 19.  cvSaveImage( “copy.png”, image ); 20.  cvNamedWindow( &quot;test&quot;, 1 ); 21.  cvShowImage( &quot;test&quot;, image ); 22.  cvWaitKey(); 23.  return 0; } Radial gradient
How to build and run the program? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Program Quick Review ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],1. #include <cxcore.h> 2. #include <highgui.h> 3. #include <math.h> 4. int main( int argc, char** argv ) { 5.  CvPoint center; 6.  double scale=-3; 7.  IplImage* image = argc==2 ?  cvLoadImage (argv[1]) : 0; 8.  if(!image) return -1; 9.  center =  cvPoint (image->width/2,image->height/2); 10.  for(int i=0;i<image->height;i++) 11.  for(int j=0;j<image->width;j++) { 12.  double dx=(double)(j-center.x)/center.x; 13.  double dy=(double)(i-center.y)/center.y; 14.  double weight=exp((dx*dx+dy*dy)*scale); 15.  uchar* ptr = & CV_IMAGE_ELEM (image,uchar,i,j*3); 16.  ptr[0] =  cvRound (ptr[0]*weight); 17.  ptr[1] =  cvRound (ptr[1]*weight); 18.  ptr[2] =  cvRound (ptr[2]*weight);  } 19.  cvSaveImage ( “copy.png”, image ); 20.  cvNamedWindow ( &quot;test&quot;, 1 ); 21.  cvShowImage ( &quot;test&quot;, image ); 22.  cvWaitKey (); 23.  return 0; }
What else HighGUI can do? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Windows ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Image I/O ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],IplImage* img = cvLoadImage(“picture.jpeg”,-1); if( img ) cvSaveImage( “picture.png”, img );
Waiting for keys… ,[object Object],[object Object],[object Object],[object Object],[object Object],// opencv/samples/c/delaunay.c … for(…) { … int c = cvWaitKey(100); if( c >= 0 ) // key_pressed break; } delaunay.c, 240 lines
Trackbars ,[object Object],[object Object],[object Object],[object Object],// opencv/samples/c/morphology.c int dilate_pos=0; // initial position value void Dilate(int pos) { …  cvShowImage( “E&D”, erode_result ); } int main(…){ … cvCreateTrackbar(“Dilate”,”E&D”, &dilate_pos,10,Dilate); … cvWaitKey(0); // check for events & process them ...} morphology.c, 126 lines
Mouse Events ,[object Object],[object Object],// opencv/samples/c/lkdemo.c void on_mouse(int event,int x,int y,int flags, void* param) { … } int main(…){ … cvSetMouseCallback(“LkDemo”,on_mouse,0); … cvWaitKey(0); // check for events & process them … } Scroll forward for example  
Video I/O API ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Video I/O Example // opencv/samples/c/lkdemo.c int main(…){ … CvCapture* capture = <…> ? cvCaptureFromCAM(camera_id) : cvCaptureFromFile(path); if( !capture ) return -1; for(;;) { IplImage* frame=cvQueryFrame(capture); if(!frame) break; // … copy and process image cvShowImage( “LkDemo”, result ); c=cvWaitKey(30); // run at ~20-30fps speed if(c >= 0) { // process key }} cvReleaseCapture(&capture);}  lkdemo.c, 190 lines (needs camera to run)
Using OpenCV in User Apps ,[object Object],// was (A – NxN matrix, b – Nx1 right-side vector, x – solution): some_old_least_sq_func_32f( /*  float*  */ A, /*  int  */ N, /*  int  */ N, /*  float*  */ b, /*  float*  */ x); // has been converted to: { CvMat _A=cvMat(N,N,CV_32F,A), _b=cvMat(N,1,CV_32F,b), _x=cvMat(N,1,CV_32F,x); cvSolve( &_A, &_b, &_x, CV_SVD ); } ,[object Object],[object Object],[object Object],[object Object]
Using OpenCV in User Apps (II) Case 2. Film Grain DirectShow filter prototype. // inside DirectShow filter Transform method …  pMediaSample->GetPointer(&pData); AM_MEDIA_TYPE* pType = &m_pInput->CurrentMediaType(); BITMAPINFOHEADER *bh = &((VIDEOINFOHEADER *)pType->pbFormat)->bmiHeader; IplImage* img = cvCreateImageHeader(cvSize(bh.biWidth,bh.biHeight), 8, 3); cvSetData( img, pData, (bh.biWdith*3 + 3) & -4 ); cvCvtColor( img, img, CV_BGR2YCrCb ); IplImage* Y=cvCreateImage(cvGetSize(img),8,1); cvSplit(img,Y,0,0,0); IplImage* Yf=cvCreateImage(cvGetSize(img),32,1); CvRNG rng=cvRNG(<seed>); cvRandArr(&rng,Yf,cvScalarAll(0),cvScalarAll(GRAIN_MAG),CV_RAND_NORMAL); cvSmooth(Yf,Yf,CV_GAUSSIAN,GRAIN_SIZE,0,GRAIN_SIZE*0.5); cvAcc(Y, Yf); cvConvert(Yf,Y); cvMerge(Y,0,0,0,img); cvCvtColor( img, img, CV_YCrCb2BGR ); cvReleaseImage(&Yf); cvReleaseImage(&Y); cvReleaseImageHeader(&img);…
Using OpenCV in User Apps (III) Case 3. Visualization inside some test program (hypothetical example,yet quite real too). //  was …  /* some image processing code containing bug */ … //  has been converted to  … …  /* at this point we have the results */ #if VISUALIZE #include <highgui.h> #pragma comment(“lib”,”cxcore.lib”) #pragma comment(“lib”,”highgui.lib”) CvMat hdr; cvInitMatHeader (&hdr,200/*height*/,320/*width*/,CV_8UC3, data_ptr); CvMat* vis_copy=cvCloneMat(&hdr); cvNamedWindow(“test”,1); cvCircle (vis_copy, cvCenter(bug_x,bug_y), 30, CV_RGB(255,0,0), 3, CV_AA ); // mark the suspicious area cvShowImage(“test”,vis_copy); cvWaitKey (0 /* or use some delay, e.g. 1000 */); // cvSaveImage( “buggy.png”, vis_copy ); // if need, save for post-mortem analysis //  cvDestroyWindow (“test”); // if need #endif
What can be drawn in image (besides circles)? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using OpenCV with IPP #include <cv.h> #include <highgui.h> #include <ipp.h> #include <stdio.h> int main(int,char**){ const int M=3; IppiSize msz={M,M}; IppiPoint ma={M/2,M/2}; IplImage* img=cvLoadImage(“lena.jpg”,1); IplImage* med1= cvCreateImage (cvGetSize(img),8,3); IplImage* med2= cvCloneImage (med1); int64 t0 =  cvGetTickCount() ,t1,t2; IppiSize sz = {img->width-M+1,img->height-M+1}; double isz=1./(img->width*img->height); cvSmooth (img,med1,CV_MEDIAN,M); // use IPP via OpenCV t0= cvGetTickCount ()-t0; cvUseOptimized (0); // unload IPP t1 =  cvGetTickCount (); cvSmooth (img,med1,CV_MEDIAN,M); // use C code t1= cvGetTickCount ()-t1; t2= cvGetTickCount (); ippiMedianFilter_8u_C3R ( // use IPP directly & CV_IMAGE_ELEM (img,uchar,M/2,M/2*3), img->widthStep, & CV_IMAGE_ELEM (med1,uchar,M/2,M/2*3), med1->widthStep, sz, msz, ma ); t2= cvGetTickCount ()-t2; printf(“t0=%.2f, t1=%.2f, t2=%.2f”, (double)t0*isz,(double)t1*isz,(double)t2*isz); return 0; } Triple 3x3 median filter
How does it works? ,[object Object],// cv/src/_cvipp.h … IPCVAPI_EX(CvStatus, icvFilterMedian_8u_C3R, “ippiFilterMedian_8u_C3R”, CV_PLUGINS1(CV_PLUGIN_IPPI), (const void* src, int srcstep, void* dst, int dststep, CvSize roi, CvSize ksize, CvPoint anchor )) … // cv/src/cvswitcher.cpp … #undef IPCVAPI_EX #define IPCVAPI_EX() … static CvPluginFuncInfo cv_ipp_tab[] = { #undef _CV_IPP_H_ /* with redefined IPCVAPI_EX every function declaration turns to the table entry */ #include &quot;_cvipp.h“ #undef _CV_IPP_H_ {0, 0, 0, 0, 0} }; static CvModuleInfo cv_module = { 0, &quot;cv&quot;, &quot;beta 5 (0.9.7)&quot;, cv_ipp_tab }; static int loaded_functions = cvRegisterModule( &cv_module ); … // cv/src/cvsmooth.cpp icvFilterMedian_8u_C3R_t icvFilterMedian_8u_C3R_p = 0; void cvSmooth() { if( icvFilterMedian_8u_C3R_p ) { /* use IPP */ } else { /* use C code */… }
Dynamic Structures (when 2d array is not enough) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],// construct sequence of non-zero pixel locations CvSeq*  get_non_zeros( const IplImage* img,  CvMemStorage*  storage ) { CvSeq * seq =  cvCreateSeq ( CV_32SC2, sizeof(CvSeq), sizeof(CvPoint), storage ); for( int i = 0; i < img->height; i++ ) for( int j = 0; j < img->width; j++ ) if( CV_IMAGE_ELEM(img,uchar,i,j) ) { CvPoint pt={j,i};  cvSeqPush ( seq, &pt ); } return seq; }
Memory Storages … ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sequences ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sets and Sparse Matrices ,[object Object],[object Object],// Collecting the image colors CvSparseMat*  get_color_map( const IplImage* img ) { int dims[] = { 256, 256, 256 }; CvSparseMat * cmap =  cvCreateSparseMat (3, dims, CV_32SC1); for( int i = 0; i < img->height; i++ ) for( int j = 0; j < img->width; j++ ) {  uchar* ptr=&CV_IMAGE_ELEM(img,uchar,i,j*3); int idx[] = {ptr[0],ptr[1],ptr[2]}; ((int*) cvPtrND (cmap,idx))[0]++; } // print the map CvSparseMatIterator  it; for( CvSparseNode  *node =  cvInitSparseMatIterator ( mat, &iterator ); node != 0; node =  cvGetNextSparseNode ( &iterator )) { int* idx =  CV_NODE_IDX (cmap,node); int count=*(int*) CV_NODE_VAL (cmap,idx); printf( “(b=%d,g=%d,r=%d): %d”, idx[0], idx[1], idx[2], count ); } return cmap; }
Save your data (to load it then) ,[object Object],[object Object],[object Object],[object Object],// somewhere deep in your code… you get 5x5 // matrix that you’d want to save { CvMat A = cvMat( 5, 5, CV_32F, the_matrix_data ); cvSave ( “my_matrix.xml”, &A ); } // to load it then in some other program use … CvMat* A1 = (CvMat*) cvLoad ( “my_matrix.xml” ); <?xml version=&quot;1.0&quot;?> <opencv_storage> <my_matrix type_id=&quot;opencv-matrix&quot;> <rows>5</rows> <cols>5</cols> <dt>f</dt> <data> 1. 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 1.</data></my_matrix> </opencv_storage> my_matrix.xml
So what about config file? CvFileStorage * fs =  cvOpenFileStorage (“cfg.xml”, 0,  CV_STORAGE_WRITE ); cvWriteInt ( fs, “frame_count”, 10 ); cvWriteStartWriteStruct ( fs, “frame_size”, CV_NODE_SEQ); cvWriteInt( fs, 0, 320 ); cvWriteint( fs, 0, 200 ); cvEndWriteStruct (fs); cvWrite ( fs, “color_cvt_matrix”, cmatrix ); cvReleaseFileStorage ( &fs ); Writing config file CvFileStorage* fs = cvOpenFileStorage(“cfg.xml”, 0, CV_STORAGE_READ); int frame_count =  cvReadIntByName ( fs, 0, “frame_count”, 10 /* default value */ ); CvSeq* s =  cvGetFileNodeByName (fs,0,”frame_size”)->data.seq; int frame_width =  cvReadInt ( (CvFileNode*)cvGetSeqElem(s,0) ); int frame_height = cvReadInt( (CvFileNode*)cvGetSeqElem(s,1) ); CvMat* color_cvt_matrix = (CvMat*)cvRead(fs,0,”color_cvt_matrix”); cvReleaseFileStorage( &fs ); Reading config file <?xml version=&quot;1.0&quot;?> <opencv_storage> <frame_count>10</frame_count> <frame_size>320 200</frame_size> <color_cvt_matrix type_id=&quot;opencv-matrix&quot;> <rows>3</rows> <cols>3</cols> <dt>f</dt> <data>…</data></color_cvt_matrix> </opencv_storage> cfg.xml
Some OpenCV Tips and Tricks ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Where to get more information? ,[object Object],[object Object],[object Object]
Thank you! Questions?

Más contenido relacionado

La actualidad más candente

Feature detection and matching
Feature detection and matchingFeature detection and matching
Feature detection and matchingKuppusamy P
 
PHP 8.1 - What's new and changed
PHP 8.1 - What's new and changedPHP 8.1 - What's new and changed
PHP 8.1 - What's new and changedAyesh Karunaratne
 
Unity Internals: Memory and Performance
Unity Internals: Memory and PerformanceUnity Internals: Memory and Performance
Unity Internals: Memory and PerformanceDevGAMM Conference
 
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14AMD Developer Central
 
Dx11 performancereloaded
Dx11 performancereloadedDx11 performancereloaded
Dx11 performancereloadedmistercteam
 
Visual odometry presentation_without_video
Visual odometry presentation_without_videoVisual odometry presentation_without_video
Visual odometry presentation_without_videoIan Sa
 
NVIDIA OpenGL 4.6 in 2017
NVIDIA OpenGL 4.6 in 2017NVIDIA OpenGL 4.6 in 2017
NVIDIA OpenGL 4.6 in 2017Mark Kilgard
 
camera-based Lane detection by deep learning
camera-based Lane detection by deep learningcamera-based Lane detection by deep learning
camera-based Lane detection by deep learningYu Huang
 
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic SegmentationSemantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation岳華 杜
 
Image proccessing slide share
Image proccessing slide shareImage proccessing slide share
Image proccessing slide shareSyedShaiby
 
Digital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency DomainDigital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency DomainMostafa G. M. Mostafa
 
Secrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics TechnologySecrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics TechnologyTiago Sousa
 
OpenGL 4.5 Update for NVIDIA GPUs
OpenGL 4.5 Update for NVIDIA GPUsOpenGL 4.5 Update for NVIDIA GPUs
OpenGL 4.5 Update for NVIDIA GPUsMark Kilgard
 
오픈소스 GIS 교육 - PostGIS
오픈소스 GIS 교육 - PostGIS오픈소스 GIS 교육 - PostGIS
오픈소스 GIS 교육 - PostGISJungHwan Yun
 
Introduction to Skia by Ryan Chou @20141008
Introduction to Skia by Ryan Chou @20141008Introduction to Skia by Ryan Chou @20141008
Introduction to Skia by Ryan Chou @20141008Ryan Chou
 
Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해SangYun Yi
 
Lidar for Autonomous Driving II (via Deep Learning)
Lidar for Autonomous Driving II (via Deep Learning)Lidar for Autonomous Driving II (via Deep Learning)
Lidar for Autonomous Driving II (via Deep Learning)Yu Huang
 
IndirectDraw with unity
IndirectDraw with unityIndirectDraw with unity
IndirectDraw with unityJung Suk Ko
 

La actualidad más candente (20)

Feature detection and matching
Feature detection and matchingFeature detection and matching
Feature detection and matching
 
PHP 8.1 - What's new and changed
PHP 8.1 - What's new and changedPHP 8.1 - What's new and changed
PHP 8.1 - What's new and changed
 
Unity Internals: Memory and Performance
Unity Internals: Memory and PerformanceUnity Internals: Memory and Performance
Unity Internals: Memory and Performance
 
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
 
Dx11 performancereloaded
Dx11 performancereloadedDx11 performancereloaded
Dx11 performancereloaded
 
Visual odometry presentation_without_video
Visual odometry presentation_without_videoVisual odometry presentation_without_video
Visual odometry presentation_without_video
 
NVIDIA OpenGL 4.6 in 2017
NVIDIA OpenGL 4.6 in 2017NVIDIA OpenGL 4.6 in 2017
NVIDIA OpenGL 4.6 in 2017
 
camera-based Lane detection by deep learning
camera-based Lane detection by deep learningcamera-based Lane detection by deep learning
camera-based Lane detection by deep learning
 
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic SegmentationSemantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
 
Image proccessing slide share
Image proccessing slide shareImage proccessing slide share
Image proccessing slide share
 
Digital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency DomainDigital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency Domain
 
Hog and sift
Hog and siftHog and sift
Hog and sift
 
Secrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics TechnologySecrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics Technology
 
OpenGL Introduction
OpenGL IntroductionOpenGL Introduction
OpenGL Introduction
 
OpenGL 4.5 Update for NVIDIA GPUs
OpenGL 4.5 Update for NVIDIA GPUsOpenGL 4.5 Update for NVIDIA GPUs
OpenGL 4.5 Update for NVIDIA GPUs
 
오픈소스 GIS 교육 - PostGIS
오픈소스 GIS 교육 - PostGIS오픈소스 GIS 교육 - PostGIS
오픈소스 GIS 교육 - PostGIS
 
Introduction to Skia by Ryan Chou @20141008
Introduction to Skia by Ryan Chou @20141008Introduction to Skia by Ryan Chou @20141008
Introduction to Skia by Ryan Chou @20141008
 
Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해
 
Lidar for Autonomous Driving II (via Deep Learning)
Lidar for Autonomous Driving II (via Deep Learning)Lidar for Autonomous Driving II (via Deep Learning)
Lidar for Autonomous Driving II (via Deep Learning)
 
IndirectDraw with unity
IndirectDraw with unityIndirectDraw with unity
IndirectDraw with unity
 

Destacado

A basic introduction to open cv for image processing
A basic introduction to open cv for image processingA basic introduction to open cv for image processing
A basic introduction to open cv for image processingChu Lam
 
Who is ursula ellis
Who is ursula ellisWho is ursula ellis
Who is ursula ellisursulaellis
 
Guide: How to Build OpenCV 3.0.0
Guide: How to Build OpenCV 3.0.0Guide: How to Build OpenCV 3.0.0
Guide: How to Build OpenCV 3.0.0André Moreira
 
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel HordesPyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordeskgrandis
 
Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)Luigi De Russis
 
I Rock Therefore I Am. 20 Legendary Quotes from Prince
I Rock Therefore I Am. 20 Legendary Quotes from PrinceI Rock Therefore I Am. 20 Legendary Quotes from Prince
I Rock Therefore I Am. 20 Legendary Quotes from PrinceEmpowered Presentations
 

Destacado (7)

A basic introduction to open cv for image processing
A basic introduction to open cv for image processingA basic introduction to open cv for image processing
A basic introduction to open cv for image processing
 
Who is ursula ellis
Who is ursula ellisWho is ursula ellis
Who is ursula ellis
 
Guide: How to Build OpenCV 3.0.0
Guide: How to Build OpenCV 3.0.0Guide: How to Build OpenCV 3.0.0
Guide: How to Build OpenCV 3.0.0
 
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel HordesPyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes
 
Write good papers
Write good papersWrite good papers
Write good papers
 
Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)
 
I Rock Therefore I Am. 20 Legendary Quotes from Prince
I Rock Therefore I Am. 20 Legendary Quotes from PrinceI Rock Therefore I Am. 20 Legendary Quotes from Prince
I Rock Therefore I Am. 20 Legendary Quotes from Prince
 

Similar a OPENCVSTART

PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...Andrey Karpov
 
Objective-C Runtime overview
Objective-C Runtime overviewObjective-C Runtime overview
Objective-C Runtime overviewFantageek
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 MinigamesSusan Gold
 
Getting started with open cv in raspberry pi
Getting started with open cv in raspberry piGetting started with open cv in raspberry pi
Getting started with open cv in raspberry piJayaprakash Nagaruru
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
How to instantiate any view controller for free
How to instantiate any view controller for freeHow to instantiate any view controller for free
How to instantiate any view controller for freeBenotCaron
 
Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Patrick Chanezon
 
Threaded Programming
Threaded ProgrammingThreaded Programming
Threaded ProgrammingSri Prasanna
 
SPU gameplay
SPU gameplaySPU gameplay
SPU gameplaySlide_N
 
Moving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresMoving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresFrits Van Der Holst
 
Forge - DevCon 2016: Visual Reporting with Connected Design Data
Forge - DevCon 2016: Visual Reporting with Connected Design DataForge - DevCon 2016: Visual Reporting with Connected Design Data
Forge - DevCon 2016: Visual Reporting with Connected Design DataAutodesk
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...DroidConTLV
 

Similar a OPENCVSTART (20)

PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
 
Objective-C Runtime overview
Objective-C Runtime overviewObjective-C Runtime overview
Objective-C Runtime overview
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 Minigames
 
Getting started with open cv in raspberry pi
Getting started with open cv in raspberry piGetting started with open cv in raspberry pi
Getting started with open cv in raspberry pi
 
OpenCV Introduction
OpenCV IntroductionOpenCV Introduction
OpenCV Introduction
 
OpenCVの基礎
OpenCVの基礎OpenCVの基礎
OpenCVの基礎
 
Facedetect
FacedetectFacedetect
Facedetect
 
Html5
Html5Html5
Html5
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
Rcp by example
Rcp by exampleRcp by example
Rcp by example
 
How to instantiate any view controller for free
How to instantiate any view controller for freeHow to instantiate any view controller for free
How to instantiate any view controller for free
 
Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?Google's HTML5 Work: what's next?
Google's HTML5 Work: what's next?
 
Power ai image-pipeline
Power ai image-pipelinePower ai image-pipeline
Power ai image-pipeline
 
Threaded Programming
Threaded ProgrammingThreaded Programming
Threaded Programming
 
SPU gameplay
SPU gameplaySPU gameplay
SPU gameplay
 
Intro to HTML5
Intro to HTML5Intro to HTML5
Intro to HTML5
 
Moving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresMoving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventures
 
Qt Programming on TI Processors
Qt Programming on TI ProcessorsQt Programming on TI Processors
Qt Programming on TI Processors
 
Forge - DevCon 2016: Visual Reporting with Connected Design Data
Forge - DevCon 2016: Visual Reporting with Connected Design DataForge - DevCon 2016: Visual Reporting with Connected Design Data
Forge - DevCon 2016: Visual Reporting with Connected Design Data
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 

Más de antiw

Cvpr2010 open source vision software, intro and training part viii point clou...
Cvpr2010 open source vision software, intro and training part viii point clou...Cvpr2010 open source vision software, intro and training part viii point clou...
Cvpr2010 open source vision software, intro and training part viii point clou...antiw
 
Cvpr2010 open source vision software, intro and training part vii point cloud...
Cvpr2010 open source vision software, intro and training part vii point cloud...Cvpr2010 open source vision software, intro and training part vii point cloud...
Cvpr2010 open source vision software, intro and training part vii point cloud...antiw
 
graphical models for the Internet
graphical models for the Internetgraphical models for the Internet
graphical models for the Internetantiw
 
Recent Advances in Computer Vision
Recent Advances in Computer VisionRecent Advances in Computer Vision
Recent Advances in Computer Visionantiw
 
15 pieces of advice i wish my ph d advisor had given me
15 pieces of advice i wish my ph d advisor had given me15 pieces of advice i wish my ph d advisor had given me
15 pieces of advice i wish my ph d advisor had given meantiw
 
Randy pauschtimemanagement2007
Randy pauschtimemanagement2007Randy pauschtimemanagement2007
Randy pauschtimemanagement2007antiw
 
Write a research paper howto - good presentation
Write a research paper   howto - good presentationWrite a research paper   howto - good presentation
Write a research paper howto - good presentationantiw
 
15 pieces of advice i wish my ph d advisor had given me
15 pieces of advice i wish my ph d advisor had given me15 pieces of advice i wish my ph d advisor had given me
15 pieces of advice i wish my ph d advisor had given meantiw
 
Note beamer
Note beamerNote beamer
Note beamerantiw
 

Más de antiw (9)

Cvpr2010 open source vision software, intro and training part viii point clou...
Cvpr2010 open source vision software, intro and training part viii point clou...Cvpr2010 open source vision software, intro and training part viii point clou...
Cvpr2010 open source vision software, intro and training part viii point clou...
 
Cvpr2010 open source vision software, intro and training part vii point cloud...
Cvpr2010 open source vision software, intro and training part vii point cloud...Cvpr2010 open source vision software, intro and training part vii point cloud...
Cvpr2010 open source vision software, intro and training part vii point cloud...
 
graphical models for the Internet
graphical models for the Internetgraphical models for the Internet
graphical models for the Internet
 
Recent Advances in Computer Vision
Recent Advances in Computer VisionRecent Advances in Computer Vision
Recent Advances in Computer Vision
 
15 pieces of advice i wish my ph d advisor had given me
15 pieces of advice i wish my ph d advisor had given me15 pieces of advice i wish my ph d advisor had given me
15 pieces of advice i wish my ph d advisor had given me
 
Randy pauschtimemanagement2007
Randy pauschtimemanagement2007Randy pauschtimemanagement2007
Randy pauschtimemanagement2007
 
Write a research paper howto - good presentation
Write a research paper   howto - good presentationWrite a research paper   howto - good presentation
Write a research paper howto - good presentation
 
15 pieces of advice i wish my ph d advisor had given me
15 pieces of advice i wish my ph d advisor had given me15 pieces of advice i wish my ph d advisor had given me
15 pieces of advice i wish my ph d advisor had given me
 
Note beamer
Note beamerNote beamer
Note beamer
 

Último

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Último (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

OPENCVSTART

  • 1. Getting Started with OpenCV Vadim Pisarevsky (vadim.pisarevsky@intel.com)
  • 2.
  • 3.
  • 4.
  • 5. Now the question is: Should you use it?
  • 6. OpenCV structure CXCORE basic structures and algoritms, XML support, drawing functions CV Image processing and vision algorithms HighGUI GUI, Image and Video I/O We will mostly focus on these two in this presentation
  • 7. First OpenCV Program 1. #include <cxcore.h> 2. #include <highgui.h> 3. #include <math.h> 4. int main( int argc, char** argv ) { 5. CvPoint center; 6. double scale=-3; 7. IplImage* image = argc==2 ? cvLoadImage(argv[1]) : 0; 8. if(!image) return -1; 9. center = cvPoint(image->width/2,image->height/2); 10. for(int i=0;i<image->height;i++) 11. for(int j=0;j<image->width;j++) { 12. double dx=(double)(j-center.x)/center.x; 13. double dy=(double)(i-center.y)/center.y; 14. double weight=exp((dx*dx+dy*dy)*scale); 15. uchar* ptr = &CV_IMAGE_ELEM(image,uchar,i,j*3); 16. ptr[0] = cvRound(ptr[0]*weight); 17. ptr[1] = cvRound(ptr[1]*weight); 18. ptr[2] = cvRound(ptr[2]*weight); } 19. cvSaveImage( “copy.png”, image ); 20. cvNamedWindow( &quot;test&quot;, 1 ); 21. cvShowImage( &quot;test&quot;, image ); 22. cvWaitKey(); 23. return 0; } Radial gradient
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17. Video I/O Example // opencv/samples/c/lkdemo.c int main(…){ … CvCapture* capture = <…> ? cvCaptureFromCAM(camera_id) : cvCaptureFromFile(path); if( !capture ) return -1; for(;;) { IplImage* frame=cvQueryFrame(capture); if(!frame) break; // … copy and process image cvShowImage( “LkDemo”, result ); c=cvWaitKey(30); // run at ~20-30fps speed if(c >= 0) { // process key }} cvReleaseCapture(&capture);} lkdemo.c, 190 lines (needs camera to run)
  • 18.
  • 19. Using OpenCV in User Apps (II) Case 2. Film Grain DirectShow filter prototype. // inside DirectShow filter Transform method … pMediaSample->GetPointer(&pData); AM_MEDIA_TYPE* pType = &m_pInput->CurrentMediaType(); BITMAPINFOHEADER *bh = &((VIDEOINFOHEADER *)pType->pbFormat)->bmiHeader; IplImage* img = cvCreateImageHeader(cvSize(bh.biWidth,bh.biHeight), 8, 3); cvSetData( img, pData, (bh.biWdith*3 + 3) & -4 ); cvCvtColor( img, img, CV_BGR2YCrCb ); IplImage* Y=cvCreateImage(cvGetSize(img),8,1); cvSplit(img,Y,0,0,0); IplImage* Yf=cvCreateImage(cvGetSize(img),32,1); CvRNG rng=cvRNG(<seed>); cvRandArr(&rng,Yf,cvScalarAll(0),cvScalarAll(GRAIN_MAG),CV_RAND_NORMAL); cvSmooth(Yf,Yf,CV_GAUSSIAN,GRAIN_SIZE,0,GRAIN_SIZE*0.5); cvAcc(Y, Yf); cvConvert(Yf,Y); cvMerge(Y,0,0,0,img); cvCvtColor( img, img, CV_YCrCb2BGR ); cvReleaseImage(&Yf); cvReleaseImage(&Y); cvReleaseImageHeader(&img);…
  • 20. Using OpenCV in User Apps (III) Case 3. Visualization inside some test program (hypothetical example,yet quite real too). // was … /* some image processing code containing bug */ … // has been converted to … … /* at this point we have the results */ #if VISUALIZE #include <highgui.h> #pragma comment(“lib”,”cxcore.lib”) #pragma comment(“lib”,”highgui.lib”) CvMat hdr; cvInitMatHeader (&hdr,200/*height*/,320/*width*/,CV_8UC3, data_ptr); CvMat* vis_copy=cvCloneMat(&hdr); cvNamedWindow(“test”,1); cvCircle (vis_copy, cvCenter(bug_x,bug_y), 30, CV_RGB(255,0,0), 3, CV_AA ); // mark the suspicious area cvShowImage(“test”,vis_copy); cvWaitKey (0 /* or use some delay, e.g. 1000 */); // cvSaveImage( “buggy.png”, vis_copy ); // if need, save for post-mortem analysis // cvDestroyWindow (“test”); // if need #endif
  • 21.
  • 22. Using OpenCV with IPP #include <cv.h> #include <highgui.h> #include <ipp.h> #include <stdio.h> int main(int,char**){ const int M=3; IppiSize msz={M,M}; IppiPoint ma={M/2,M/2}; IplImage* img=cvLoadImage(“lena.jpg”,1); IplImage* med1= cvCreateImage (cvGetSize(img),8,3); IplImage* med2= cvCloneImage (med1); int64 t0 = cvGetTickCount() ,t1,t2; IppiSize sz = {img->width-M+1,img->height-M+1}; double isz=1./(img->width*img->height); cvSmooth (img,med1,CV_MEDIAN,M); // use IPP via OpenCV t0= cvGetTickCount ()-t0; cvUseOptimized (0); // unload IPP t1 = cvGetTickCount (); cvSmooth (img,med1,CV_MEDIAN,M); // use C code t1= cvGetTickCount ()-t1; t2= cvGetTickCount (); ippiMedianFilter_8u_C3R ( // use IPP directly & CV_IMAGE_ELEM (img,uchar,M/2,M/2*3), img->widthStep, & CV_IMAGE_ELEM (med1,uchar,M/2,M/2*3), med1->widthStep, sz, msz, ma ); t2= cvGetTickCount ()-t2; printf(“t0=%.2f, t1=%.2f, t2=%.2f”, (double)t0*isz,(double)t1*isz,(double)t2*isz); return 0; } Triple 3x3 median filter
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29. So what about config file? CvFileStorage * fs = cvOpenFileStorage (“cfg.xml”, 0, CV_STORAGE_WRITE ); cvWriteInt ( fs, “frame_count”, 10 ); cvWriteStartWriteStruct ( fs, “frame_size”, CV_NODE_SEQ); cvWriteInt( fs, 0, 320 ); cvWriteint( fs, 0, 200 ); cvEndWriteStruct (fs); cvWrite ( fs, “color_cvt_matrix”, cmatrix ); cvReleaseFileStorage ( &fs ); Writing config file CvFileStorage* fs = cvOpenFileStorage(“cfg.xml”, 0, CV_STORAGE_READ); int frame_count = cvReadIntByName ( fs, 0, “frame_count”, 10 /* default value */ ); CvSeq* s = cvGetFileNodeByName (fs,0,”frame_size”)->data.seq; int frame_width = cvReadInt ( (CvFileNode*)cvGetSeqElem(s,0) ); int frame_height = cvReadInt( (CvFileNode*)cvGetSeqElem(s,1) ); CvMat* color_cvt_matrix = (CvMat*)cvRead(fs,0,”color_cvt_matrix”); cvReleaseFileStorage( &fs ); Reading config file <?xml version=&quot;1.0&quot;?> <opencv_storage> <frame_count>10</frame_count> <frame_size>320 200</frame_size> <color_cvt_matrix type_id=&quot;opencv-matrix&quot;> <rows>3</rows> <cols>3</cols> <dt>f</dt> <data>…</data></color_cvt_matrix> </opencv_storage> cfg.xml
  • 30.
  • 31.