SlideShare a Scribd company logo
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?

More Related Content

What's hot

Face detection and recognition
Face detection and recognitionFace detection and recognition
Face detection and recognition
Derek Budde
 
Raster vs vector
Raster vs vectorRaster vs vector
Raster vs vector
akn4fotos
 
418 Automated Criminal Identification System using Face Detection and.pptx
418 Automated Criminal Identification System using Face Detection and.pptx418 Automated Criminal Identification System using Face Detection and.pptx
418 Automated Criminal Identification System using Face Detection and.pptx
Shivanig12
 
Computer Graphics - Lecture 02 transformation
Computer Graphics - Lecture 02 transformationComputer Graphics - Lecture 02 transformation
Computer Graphics - Lecture 02 transformation
💻 Anton Gerdelan
 
Fundamentals of Machine Vision- Lighting
Fundamentals of Machine Vision- LightingFundamentals of Machine Vision- Lighting
Fundamentals of Machine Vision- LightingPete Kepf, CVP
 
Automated Face Detection System
Automated Face Detection SystemAutomated Face Detection System
Automated Face Detection System
Abhiroop Ghatak
 
Introduction to Virtual Reality
Introduction to Virtual RealityIntroduction to Virtual Reality
Introduction to Virtual Reality
KAVITHADEVICS
 
Computer animation
Computer animationComputer animation
Computer animation
shusrusha
 
AI Computer vision
AI Computer visionAI Computer vision
AI Computer vision
Kashafnaz2
 
Eye mouse
Eye mouseEye mouse
Eye mouse
SUHAS BADAM
 
2018.02 intro to visual odometry
2018.02 intro to visual odometry2018.02 intro to visual odometry
2018.02 intro to visual odometry
BrianHoltPhD
 
Eye Movement based Human Computer Interaction Technique
Eye Movement based Human Computer Interaction TechniqueEye Movement based Human Computer Interaction Technique
Eye Movement based Human Computer Interaction Technique
Jobin George
 
Image proccessing slide share
Image proccessing slide shareImage proccessing slide share
Image proccessing slide share
SyedShaiby
 
Tele immersion
Tele immersionTele immersion
Tele immersion
ronak patel
 
Introduction of slam
Introduction of slamIntroduction of slam
Introduction of slam
Hung-Chih Chang
 
Cyborg techseminar
Cyborg techseminarCyborg techseminar
Cyborg techseminar
priyanka reddy
 
Introduction and Application of Computer Graphics.
Introduction and Application of Computer Graphics.Introduction and Application of Computer Graphics.
Introduction and Application of Computer Graphics.
Bhautik Jethva
 

What's hot (20)

Face detection and recognition
Face detection and recognitionFace detection and recognition
Face detection and recognition
 
Raster vs vector
Raster vs vectorRaster vs vector
Raster vs vector
 
418 Automated Criminal Identification System using Face Detection and.pptx
418 Automated Criminal Identification System using Face Detection and.pptx418 Automated Criminal Identification System using Face Detection and.pptx
418 Automated Criminal Identification System using Face Detection and.pptx
 
Computer Graphics - Lecture 02 transformation
Computer Graphics - Lecture 02 transformationComputer Graphics - Lecture 02 transformation
Computer Graphics - Lecture 02 transformation
 
Fundamentals of Machine Vision- Lighting
Fundamentals of Machine Vision- LightingFundamentals of Machine Vision- Lighting
Fundamentals of Machine Vision- Lighting
 
Automated Face Detection System
Automated Face Detection SystemAutomated Face Detection System
Automated Face Detection System
 
Introduction to Virtual Reality
Introduction to Virtual RealityIntroduction to Virtual Reality
Introduction to Virtual Reality
 
Computer animation
Computer animationComputer animation
Computer animation
 
AI Computer vision
AI Computer visionAI Computer vision
AI Computer vision
 
Eye mouse
Eye mouseEye mouse
Eye mouse
 
2018.02 intro to visual odometry
2018.02 intro to visual odometry2018.02 intro to visual odometry
2018.02 intro to visual odometry
 
Eye Movement based Human Computer Interaction Technique
Eye Movement based Human Computer Interaction TechniqueEye Movement based Human Computer Interaction Technique
Eye Movement based Human Computer Interaction Technique
 
Introduction to OpenCV
Introduction to OpenCVIntroduction to OpenCV
Introduction to OpenCV
 
Image proccessing slide share
Image proccessing slide shareImage proccessing slide share
Image proccessing slide share
 
3D-Doctor
3D-Doctor3D-Doctor
3D-Doctor
 
Tele immersion
Tele immersionTele immersion
Tele immersion
 
PPT 7.4.2015
PPT 7.4.2015PPT 7.4.2015
PPT 7.4.2015
 
Introduction of slam
Introduction of slamIntroduction of slam
Introduction of slam
 
Cyborg techseminar
Cyborg techseminarCyborg techseminar
Cyborg techseminar
 
Introduction and Application of Computer Graphics.
Introduction and Application of Computer Graphics.Introduction and Application of Computer Graphics.
Introduction and Application of Computer Graphics.
 

Viewers also liked

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 ellis
ursulaellis
 
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
André 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
 
Write good papers
Write good papersWrite good papers
Write good papers
Daniel Lemire
 
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 Prince
Empowered Presentations
 

Viewers also liked (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 to Open Cv 2005 Q4 Tutorial

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 overview
Fantageek
 
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 pi
Jayaprakash Nagaruru
 
OpenCV Introduction
OpenCV IntroductionOpenCV Introduction
OpenCV Introduction
Zachary Blair
 
OpenCVの基礎
OpenCVの基礎OpenCVの基礎
OpenCVの基礎
領一 和泉田
 
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
 
Rcp by example
Rcp by exampleRcp by example
Rcp by example
tsubramanian80
 
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
BenotCaron
 
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
 
Power ai image-pipeline
Power ai image-pipelinePower ai image-pipeline
Power ai image-pipeline
Paulo Sergio Lemes Queiroz
 
Threaded Programming
Threaded ProgrammingThreaded Programming
Threaded ProgrammingSri Prasanna
 
SPU gameplay
SPU gameplaySPU gameplay
SPU gameplay
Slide_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 adventures
Frits Van Der Holst
 
Qt Programming on TI Processors
Qt Programming on TI ProcessorsQt Programming on TI Processors
Qt Programming on TI Processors
Prabindh Sundareson
 
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
Autodesk
 
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
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
suraj pandey
 

Similar to Open Cv 2005 Q4 Tutorial (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
 

More from 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
 

More from 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
 

Recently uploaded

FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 

Open Cv 2005 Q4 Tutorial

  • 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.