SlideShare une entreprise Scribd logo
1  sur  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?

Contenu connexe

Tendances

Model view controller (mvc)
Model view controller (mvc)Model view controller (mvc)
Model view controller (mvc)M Ahsan Khan
 
What Is An SDK?
What Is An SDK?What Is An SDK?
What Is An SDK?CleverTap
 
An Introduction to ReactJS
An Introduction to ReactJSAn Introduction to ReactJS
An Introduction to ReactJSAll Things Open
 
まだ DOM 操作で消耗してるの?
まだ DOM 操作で消耗してるの?まだ DOM 操作で消耗してるの?
まだ DOM 操作で消耗してるの?Yuki Ishikawa
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooksMaulik Shah
 
UE4 Garbage Collection
UE4 Garbage CollectionUE4 Garbage Collection
UE4 Garbage CollectionQooJuice
 
MVVM in iOS presentation
MVVM in iOS presentationMVVM in iOS presentation
MVVM in iOS presentationG ABHISEK
 
The role of workflows in microservices
The role of workflows in microservicesThe role of workflows in microservices
The role of workflows in microservicesBernd Ruecker
 
덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012
덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012
덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012Esun Kim
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation洪 鹏发
 
Open Cv – An Introduction To The Vision
Open Cv – An Introduction To The VisionOpen Cv – An Introduction To The Vision
Open Cv – An Introduction To The VisionHemanth Haridas
 
Introduction to mvc architecture
Introduction to mvc architectureIntroduction to mvc architecture
Introduction to mvc architectureravindraquicsolv
 
06_게임엔진구성
06_게임엔진구성06_게임엔진구성
06_게임엔진구성noerror
 

Tendances (20)

Model view controller (mvc)
Model view controller (mvc)Model view controller (mvc)
Model view controller (mvc)
 
What Is An SDK?
What Is An SDK?What Is An SDK?
What Is An SDK?
 
Asp.net mvc 5 ppt
Asp.net mvc 5 pptAsp.net mvc 5 ppt
Asp.net mvc 5 ppt
 
An Introduction to ReactJS
An Introduction to ReactJSAn Introduction to ReactJS
An Introduction to ReactJS
 
まだ DOM 操作で消耗してるの?
まだ DOM 操作で消耗してるの?まだ DOM 操作で消耗してるの?
まだ DOM 操作で消耗してるの?
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
UE4 Garbage Collection
UE4 Garbage CollectionUE4 Garbage Collection
UE4 Garbage Collection
 
MVVM in iOS presentation
MVVM in iOS presentationMVVM in iOS presentation
MVVM in iOS presentation
 
The role of workflows in microservices
The role of workflows in microservicesThe role of workflows in microservices
The role of workflows in microservices
 
덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012
덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012
덤프 파일을 통한 사후 디버깅 실용 테크닉 NDC2012
 
Angular vs. React
Angular vs. ReactAngular vs. React
Angular vs. React
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
Open Cv – An Introduction To The Vision
Open Cv – An Introduction To The VisionOpen Cv – An Introduction To The Vision
Open Cv – An Introduction To The Vision
 
React js
React jsReact js
React js
 
MVC architecture
MVC architectureMVC architecture
MVC architecture
 
Introduction to mvc architecture
Introduction to mvc architectureIntroduction to mvc architecture
Introduction to mvc architecture
 
SOLID Ruby, SOLID Rails
SOLID Ruby, SOLID RailsSOLID Ruby, SOLID Rails
SOLID Ruby, SOLID Rails
 
An Introduction to Redux
An Introduction to ReduxAn Introduction to Redux
An Introduction to Redux
 
06_게임엔진구성
06_게임엔진구성06_게임엔진구성
06_게임엔진구성
 
Intro to React
Intro to ReactIntro to React
Intro to React
 

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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の基礎
 
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...
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
 

Plus 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
 

Plus 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
 

Dernier

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Dernier (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

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.