OpenCV (Open Source Computer Vision Library) is a high-performance C++ library for real-time computer vision and image processing modules/core/include/opencv2/core.hpp62-67. It provides a modular framework for handling image data, mathematical computations, and hardware-accelerated inference.
For a detailed exploration of the source code organization, see Repository Tour and Module Map.
The repository is organized into a core library, optional functional modules, and platform-specific build scripts. Version management is handled via CMake and propagated to core headers, with version detection from Git metadata if available CMakeLists.txt123-132.
| Directory | Contents |
|---|---|
modules/ | Functional modules (core, imgproc, dnn, etc.) modules/core/CMakeLists.txt41. |
cmake/ | Build infrastructure, dependency detection, and module macros cmake/OpenCVModule.cmake1. |
platforms/ | Platform-specific configurations (Android, iOS, etc.) CMakeLists.txt94-99. |
3rdparty/ | Bundled dependencies (zlib, libjpeg, libpng, etc.) CMakeLists.txt148-164. |
apps/ | Developer tools like annotation, interactive calibration, and visualization utilities. |
For a detailed tour of the top-level layout, directory contents, and the OpenCV 5.x module split (geometry/calib/stereo/ptcloud/features), see Repository Tour and Module Map.
Sources: CMakeLists.txt1-132, modules/core/CMakeLists.txt1-41, cmake/OpenCVModule.cmake1-25
OpenCV is structured as a collection of interdependent modules. Every module depends on opencv_core, which defines the fundamental Mat and UMat structures modules/core/include/opencv2/core.hpp64-66.
The following diagram illustrates canonical dependencies between major modules and how they bridge from low-level data structures to high-level vision tasks.
Code Entity Mapping:
opencv_core: Defined in modules/core/CMakeLists.txt modules/core/CMakeLists.txt41.opencv_imgproc: Image processing foundations.opencv_highgui: High-level GUI abstractions modules/highgui/CMakeLists.txt1.ocv_add_module: CMake macro in cmake/OpenCVModule.cmake cmake/OpenCVModule.cmake124.Sources: modules/highgui/CMakeLists.txt3-7, cmake/OpenCVModule.cmake124-127, modules/core/CMakeLists.txt41-43
ocv_add_moduleModules are registered using the ocv_add_module macro cmake/OpenCVModule.cmake124. This macro handles dependency resolution, categorization, and binding generation:
Sources: cmake/OpenCVModule.cmake77-117, cmake/OpenCVModule.cmake124-155
OpenCV uses a sophisticated CMake-based build system that manages cross-platform compilation, hardware optimization, and third-party library integration CMakeLists.txt1-166.
The configuration process is split into two passes:
System Initialization Diagram:
Sources: CMakeLists.txt42-52, [CMakeLists.txt:139], cmake/OpenCVModule.cmake54-74, cmake/OpenCVUtils.cmake1-15
For instructions on configuring, building, selecting toolchains, and running sanity checks, see Getting Started: Configure, Build, and Sanity-Check.
OpenCV abstracts platform differences through backends, particularly for GUI, video input/output, and parallel execution.
highgui)The highgui module selects a windowing backend based on target platform and available libraries modules/highgui/CMakeLists.txt43-192:
OpenCV integrates several third-party libraries for acceleration and parallel processing:
opencv_cudev and CUDA modules.Sources: modules/highgui/CMakeLists.txt43-192, modules/core/CMakeLists.txt51-81
OpenCV maintains comprehensive API documentation, extensive code samples, and developer utilities:
samples/ and categorized by language and task domains.For details on how documentation is produced, where tutorials and samples live, and developer-facing applications, see Documentation, Samples, and Developer Apps.
Sources: CMakeLists.txt1-10
This wiki is structured to mirror the codebase's directory and module topology:
ocv_add_module), and package generation.Mat, UMat), SIMD universal intrinsics, and CPU dispatch.imgproc, dnn, features2d, videoio, highgui, and geometric/3D modules.ts), GPU acceleration, and domain-specific tools.Refresh this wiki