Learning OpenCV - CERN

Transcription

Learning OpenCVGary Bradski and Adrian KaehlerO'REILLY Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo

ContentsPreface1. Overviewix1What Is OpenCV?1Who Uses OpenCV?1What Is Computer Vision?2The Origin of OpenCV6Downloading and Installing OpenCV8Getting the Latest OpenCV via CVS10More OpenCV DocumentationOpenCV Structure and Content1113Portability14Exercises152. Introduction to OpenCV16Getting Started16First Program—Display a Picture16Second Program—AVI Video18Moving Around19A Simple Transformation22A Not-So-Simple Transformation24Input from a Camera26Writing to an AVI File27Onward29Exercises29III

3. Getting to Know OpenCV31OpenCV Primitive Data Types31CvMat Matrix Structure33Ipllmage Data Structure42Matrix and Image Operators47Drawing Things77Data Persistence82Integrated Performance Primitives86Summary87Exercises874. HighGUl90A Portable Graphics Toolkit90Creating a Window91Loading an Image92Displaying Images93Working with Video102Convertlmage106Exercises1075. Image Processing109Overview109Smo othing109Image Morphology115Flood Fill124Resize129Image Pyramids130Threshold135Exercises1416. Image Transforms144Overview144Convolution144Gradients and Sobel Derivatives148Laplace150Canny151iv 1 Contents

Hough Transforms153Remap162Stretch, Shrink, Warp, and Rotate163CartToPolar and PolarToCart172LogPolar174Discrete Fourier Transform (DFT)177Discrete Cosine Transform (DCT)182Integral Images182Distance Transform185Histogram Equalization186Exercises1907. Histograms and Matching193Basic Histogram Data Structure195Accessing Histograms198Basic Manipulations with Histograms199Some More Complicated Stuff206Exercises2198. Contours222222Memory StorageSequences223Contour Finding234Another Contour Example243More to Do with Contours244Matching Contours251Exercises2629. Image Parts and Segmentation265Parts and Segments265Background Subtraction265Watershed Algorithm295Image Repair by Inpainting297Mean-Shift Segmentation298Delaunay Triangulation, Voronoi Tesselation300Exercises313Contentsv

10. Tracking and Motion316The Basics of Tracking316Corner Finding316Subpixel Corners319Invariant Features321Optical Flow322Mean-Shift and Camshift Tracking337Motion Templates341Estimators348The Condensation Algorithm364Exercises36711. Camera Models and CalibrationCamera Model371Calibration378Undistortion396Putting Calibration All Together397Rodrigues Transform401Exercises40312. Projection and 3D Vision405Projections405Affine and Perspective Transformations407POSIT: 3D Pose Estimation412Stereo Imaging415Structure from Motion453Fitting Lines in Two and Three Dimensions454Exercises45813. Machine Learningvi370459What Is Machine Learning459Common Routines in the ML Library471Mahalanobis Distance476K-Means479Naive/Normal Bayes Classifier483Binary Decision Trees486Boosting495Contents

Random Trees501Face Detection or Haar Classifier506Other Machine Learning Algorithms516Exercises51714. OpenCV's Future521Past and Future521Directions522OpenCV for nts 1 vii

Learning OpenCV Gary Bradski and Adrian Kaehler . Machine Learning 459 What Is Machine Learning 459 Common Routines in the ML Library 471 Mahalanobis Distance 476 K-Means 479 Naive/Normal Bayes Classifier 483 Binary Decision Trees 486 Boosting 495 vi Contents.