Ocean
Loading...
Searching...
No Matches
Calibration.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_CV_CALIBRATION_CALIBRATION_H
9#define META_OCEAN_CV_CALIBRATION_CALIBRATION_H
10
11#include "ocean/cv/CV.h"
12
13namespace Ocean
14{
15
16namespace CV
17{
18
19namespace Calibration
20{
21
22/**
23 * @ingroup cv
24 * @defgroup cvcalibration Ocean CV Calibration Library
25 * @{
26 * The Ocean CV Calibration Library provides a comprehensive framework for camera calibration using marker-based calibration boards.
27 *
28 * ## Overview
29 *
30 * Camera calibration is the process of determining the intrinsic and extrinsic parameters of a camera.
31 * This library uses a pattern-based approach where a calibration board containing uniquely identifiable
32 * markers is used to establish 2D-3D correspondences needed for calibration.
33 *
34 * ## Core Components
35 *
36 * ### 1. Marker System
37 *
38 * **Markers** are the fundamental building blocks of the calibration system. Each marker is a 5x5 grid
39 * of points (25 points total) that can be either black dots on a white background (positive markers)
40 * or white dots on a black background (negative markers). The marker system provides several key features:
41 *
42 * - **Unique Identification**: Each marker has a unique layout pattern that distinguishes it from others
43 * - **Orientation Detection**: Markers can be detected and identified regardless of their orientation (0°, 90°, 180°, 270°)
44 * - **Sign Variants**: Each marker can exist in positive (black on white) or negative (white on black) form
45 * - **Layout Management**: The system manages a collection of unique marker layouts that are rotation-invariant
46 *
47 * The marker layout is defined as a 5x5 grid:
48 * ```
49 * ----------------
50 * | 0 1 2 3 4 |
51 * | 5 6 7 8 9 |
52 * | 10 11 12 13 14 |
53 * | 15 16 17 18 19 |
54 * | 20 21 22 23 24 |
55 * ----------------
56 * ```
57 *
58 * The border points (used for initial detection) are arranged as:
59 * ```
60 * ----------------
61 * | 0 1 2 3 4 |
62 * | 15 5 |
63 * | 14 6 |
64 * | 13 7 |
65 * | 12 11 10 9 8 |
66 * ----------------
67 * ```
68 *
69 * ### 2. Calibration Boards
70 *
71 * **Calibration Boards** are regular grids of markers arranged in a rectangular pattern. Each board:
72 *
73 * - Contains multiple markers arranged in rows and columns
74 * - Has a unique board ID that determines the specific marker arrangement
75 * - Ensures that each marker's 4-neighborhood (adjacent markers) is unique within the board
76 * - Supports different physical sizes through the MetricCalibrationBoard class
77 *
78 * ### 3. Point Detection Pipeline
79 *
80 * The marker point detection follows a multi-stage process:
81 *
82 * #### Stage 1: Point Detection
83 * The **PointDetector** uses pattern matching to identify potential marker points in the image:
84 *
85 * - **Pattern Matching**: Uses circular or rectangular patterns of varying radii to detect blob-like structures
86 * - **Intensity Analysis**: Distinguishes between dark points (black dots) and bright points (white dots)
87 * - **Strength Calculation**: Computes detection strength based on intensity differences between center and surrounding pixels
88 * - **Non-Maximum Suppression**: Eliminates duplicate detections in overlapping regions
89 * - **Sign Detection**: Determines whether each point is positive (black) or negative (white)
90 *
91 * #### Stage 2: Marker Candidate Formation
92 * The **MarkerCandidate** system groups detected points into potential markers:
93 *
94 * - **Line Detection**: Finds continuous lines of 5 points with the same sign
95 * - **Rectangle Formation**: Extends lines to form closed rectangles of 16 border points
96 * - **Validation**: Ensures the detected rectangle has the correct geometric properties
97 * - **Point Classification**: Associates the 16 border points with the full 25-point marker layout
98 *
99 * #### Stage 3: Marker Identification
100 * Once all 25 points of a marker candidate are known:
101 *
102 * - **Layout Matching**: Compares the detected point pattern against known marker layouts
103 * - **Orientation Determination**: Identifies the marker's orientation (0°, 90°, 180°, 270°)
104 * - **ID Assignment**: Assigns the unique marker ID based on the matched layout
105 * - **Sign Confirmation**: Verifies the marker's sign (positive or negative)
106 *
107 * #### Stage 4: Neighborhood Analysis
108 * The **CalibrationBoardDetector** establishes spatial relationships:
109 *
110 * - **Neighbor Detection**: Identifies adjacent markers based on geometric proximity
111 * - **Orientation Consistency**: Ensures neighboring markers have consistent relative orientations
112 * - **Board Matching**: Compares detected marker neighborhoods against known calibration boards
113 * - **Coordinate Assignment**: Assigns board coordinates to identified markers
114 *
115 * ### 4. Camera Calibration Process
116 *
117 * The **CameraCalibrator** orchestrates the complete calibration workflow:
118 *
119 * #### Multi-Image Processing
120 * - Processes multiple images of the calibration board from different viewpoints
121 * - Accumulates 2D-3D correspondences from detected markers
122 * - Handles various camera types (pinhole, fisheye, etc.)
123 *
124 * #### Initial Parameter Estimation
125 * - Estimates initial camera field-of-view based on marker geometry
126 * - Determines initial camera poses using detected markers
127 * - Handles different camera models through the AnyCamera interface
128 *
129 * #### Optimization
130 * - Performs non-linear optimization to refine camera parameters
131 * - Uses robust estimation techniques to handle outliers
132 * - Optimizes both intrinsic parameters (focal length, distortion) and extrinsic parameters (poses)
133 *
134 * The library is platform independent and provides comprehensive debugging and visualization capabilities through the CalibrationDebugElements class.
135 * @}
136 */
137
138/**
139 * @namespace Ocean::CV::Calibration Namespace of the CV Calibration library.<p>
140 * The Namespace Ocean::CV::Calibration is used in the entire Ocean CV Calibration Library.
141 *
142 * This namespace contains all classes and functions related to marker-based camera calibration,
143 * including marker detection, calibration board management, and camera parameter estimation.
144 */
145
146// Defines OCEAN_CV_CALIBRATION_EXPORT for dll export and import.
147#if defined(_WINDOWS) && defined(OCEAN_RUNTIME_SHARED)
148 #ifdef USE_OCEAN_CV_CALIBRATION_EXPORT
149 #define OCEAN_CV_CALIBRATION_EXPORT __declspec(dllexport)
150 #else
151 #define OCEAN_CV_CALIBRATION_EXPORT __declspec(dllimport)
152 #endif
153#else
154 #define OCEAN_CV_CALIBRATION_EXPORT
155#endif
156
157}
158
159}
160
161}
162
163#endif // META_OCEAN_CV_CALIBRATION_CALIBRATION_H
The namespace covering the entire Ocean framework.
Definition Accessor.h:15