The Opencv Reference Manual, Release 2.4.3(Pdf)
Total Page:16
File Type:pdf, Size:1020Kb
The OpenCV Reference Manual Release 2.4.3 November 03, 2012 CONTENTS 1 Introduction 1 1.1 API Concepts...............................................1 2 core. The Core Functionality7 2.1 Basic Structures.............................................7 2.2 Basic C Structures and Operations.................................... 52 2.3 Dynamic Structures........................................... 83 2.4 Operations on Arrays........................................... 110 2.5 Drawing Functions............................................ 168 2.6 XML/YAML Persistence......................................... 178 2.7 XML/YAML Persistence (C API).................................... 191 2.8 Clustering................................................ 207 2.9 Utility and System Functions and Macros................................ 209 3 imgproc. Image Processing 219 3.1 Image Filtering.............................................. 219 3.2 Geometric Image Transformations.................................... 247 3.3 Miscellaneous Image Transformations.................................. 259 3.4 Histograms................................................ 273 3.5 Structural Analysis and Shape Descriptors............................... 283 3.6 Motion Analysis and Object Tracking.................................. 298 3.7 Feature Detection............................................. 302 3.8 Object Detection............................................. 313 4 highgui. High-level GUI and Media I/O 315 4.1 User Interface.............................................. 315 4.2 Reading and Writing Images and Video................................. 320 4.3 Qt New Functions............................................ 330 5 video. Video Analysis 337 5.1 Motion Analysis and Object Tracking.................................. 337 6 calib3d. Camera Calibration and 3D Reconstruction 351 6.1 Camera Calibration and 3D Reconstruction............................... 351 7 features2d. 2D Features Framework 383 7.1 Feature Detection and Description.................................... 383 7.2 Common Interfaces of Feature Detectors................................ 386 7.3 Common Interfaces of Descriptor Extractors.............................. 396 7.4 Common Interfaces of Descriptor Matchers............................... 398 i 7.5 Common Interfaces of Generic Descriptor Matchers.......................... 404 7.6 Drawing Function of Keypoints and Matches.............................. 409 7.7 Object Categorization.......................................... 411 8 objdetect. Object Detection 415 8.1 Cascade Classification.......................................... 415 8.2 Latent SVM............................................... 421 9 ml. Machine Learning 427 9.1 Statistical Models............................................ 427 9.2 Normal Bayes Classifier......................................... 430 9.3 K-Nearest Neighbors........................................... 432 9.4 Support Vector Machines........................................ 435 9.5 Decision Trees.............................................. 441 9.6 Boosting................................................. 448 9.7 Gradient Boosted Trees......................................... 452 9.8 Random Trees.............................................. 457 9.9 Extremely randomized trees....................................... 461 9.10 Expectation Maximization........................................ 462 9.11 Neural Networks............................................. 466 9.12 MLData.................................................. 471 10 flann. Clustering and Search in Multi-Dimensional Spaces 479 10.1 Fast Approximate Nearest Neighbor Search............................... 479 10.2 Clustering................................................ 483 11 gpu. GPU-accelerated Computer Vision 485 11.1 GPU Module Introduction........................................ 485 11.2 Initalization and Information....................................... 486 11.3 Data Structures.............................................. 490 11.4 Operations on Matrices.......................................... 496 11.5 Per-element Operations......................................... 500 11.6 Image Processing............................................. 508 11.7 Matrix Reductions............................................ 529 11.8 Object Detection............................................. 533 11.9 Feature Detection and Description.................................... 538 11.10 Image Filtering.............................................. 552 11.11 Camera Calibration and 3D Reconstruction............................... 567 11.12 Video Analysis.............................................. 575 12 photo. Computational Photography 599 12.1 Inpainting................................................. 599 12.2 Denoising................................................. 600 13 stitching. Images stitching 603 13.1 Stitching Pipeline............................................. 603 13.2 References................................................ 604 13.3 High Level Functionality......................................... 604 13.4 Camera.................................................. 607 13.5 Features Finding and Images Matching................................. 608 13.6 Rotation Estimation........................................... 613 13.7 Autocalibration.............................................. 617 13.8 Images Warping............................................. 618 13.9 Seam Estimation............................................. 623 13.10 Exposure Compensation......................................... 626 ii 13.11 Image Blenders.............................................. 628 14 nonfree. Non-free functionality 631 14.1 Feature Detection and Description.................................... 631 15 contrib. Contributed/Experimental Stuff 635 15.1 Stereo Correspondence.......................................... 635 15.2 FaceRecognizer - Face Recognition with OpenCV........................... 637 15.3 Retina : a Bio mimetic human retina model............................... 711 15.4 OpenFABMAP.............................................. 719 16 legacy. Deprecated stuff 725 16.1 Motion Analysis............................................. 725 16.2 Expectation Maximization........................................ 727 16.3 Histograms................................................ 730 16.4 Planar Subdivisions (C API)....................................... 732 16.5 Feature Detection and Description.................................... 739 16.6 Common Interfaces of Descriptor Extractors.............................. 746 16.7 Common Interfaces of Generic Descriptor Matchers.......................... 747 17 ocl. OpenCL-accelerated Computer Vision 749 17.1 OpenCL Module Introduction...................................... 749 17.2 Data Structures and Utility Functions.................................. 750 17.3 Data Structures.............................................. 751 17.4 Operations on Matrics.......................................... 755 17.5 Matrix Reductions............................................ 764 17.6 Image Filtering.............................................. 766 17.7 Image Processing............................................. 771 17.8 Object Detection............................................. 778 17.9 Feature Detection And Description................................... 782 Bibliography 793 iii iv CHAPTER ONE INTRODUCTION OpenCV (Open Source Computer Vision Library: http://opencv.willowgarage.com/wiki/) is an open-source BSD- licensed library that includes several hundreds of computer vision algorithms. The document describes the so-called OpenCV 2.x API, which is essentially a C++ API, as opposite to the C-based OpenCV 1.x API. The latter is described in opencv1x.pdf. OpenCV has a modular structure, which means that the package includes several shared or static libraries. The following modules are available: • core - a compact module defining basic data structures, including the dense multi-dimensional array Mat and basic functions used by all other modules. • imgproc - an image processing module that includes linear and non-linear image filtering, geometrical image transformations (resize, affine and perspective warping, generic table-based remapping), color space conversion, histograms, and so on. • video - a video analysis module that includes motion estimation, background subtraction, and object tracking algorithms. • calib3d - basic multiple-view geometry algorithms, single and stereo camera calibration, object pose estimation, stereo correspondence algorithms, and elements of 3D reconstruction. • features2d - salient feature detectors, descriptors, and descriptor matchers. • objdetect - detection of objects and instances of the predefined classes (for example, faces, eyes, mugs, people, cars, and so on). • highgui - an easy-to-use interface to video capturing, image and video codecs, as well as simple UI capabilities. • gpu - GPU-accelerated algorithms from different OpenCV modules. • ... some other helper modules, such as FLANN and Google test wrappers, Python bindings, and others. The further chapters of the document describe functionality of each module. But first, make sure to get familiar with the common API concepts used thoroughly in the library. 1.1 API Concepts cv Namespace All the OpenCV classes and functions are placed into the cv namespace. Therefore, to access this functionality from your code, use the cv:: specifier or using namespace cv; directive: