1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//! Utilities and common types for testing calibration algorithms.
//!
//! This module is public to allow use across workspace test suites,
//! but is not intended for production use. It provides shared data structures
//! and helper functions for working with calibration test data.
use crate::;
use Deserialize;
/// A calibration board view with detections for multiple cameras.
///
/// Used for stereo calibration test data where each view contains
/// corner detections from both left and right cameras.
/// Corner detections for a single camera view.
///
/// Each corner is represented as a 4-element array: `[i, j, x, y]`
/// where `(i, j)` is the board grid index and `(x, y)` is the pixel coordinate.
/// Preprocessed corner information including undistorted coordinates.
///
/// This structure is used in tests that require ground truth undistortion
/// to validate linear algorithms that assume distortion-free inputs.
/// Undistort a pixel coordinate using intrinsics and distortion model.
///
/// This is a wrapper around [`crate::math::undistort_pixel`] that accepts
/// the Brown-Conrady distortion model specifically. Use this function in tests
/// for backward compatibility, or use the generic version from the math module
/// for production code.
///
/// # Arguments
/// * `pixel` - Distorted pixel coordinate
/// * `intrinsics` - Camera intrinsics matrix K
/// * `distortion` - Brown-Conrady distortion model
///
/// # Returns
/// Undistorted normalized coordinates (on the Z=1 plane in camera frame).
/// Project normalized coordinates to pixel coordinates using intrinsics.
///
/// This is a wrapper around [`crate::math::normalized_to_pixel`]. Use this
/// function in tests for backward compatibility, or use the version from
/// the math module for production code.
///
/// # Arguments
/// * `normalized` - Normalized coordinates (on Z=1 plane)
/// * `intrinsics` - Camera intrinsics matrix K
///
/// # Returns
/// Pixel coordinates computed as `K * [x, y, 1]^T` (homogeneous division applied).
/// Build corner info list with ground truth undistortion applied.
///
/// This function processes raw corner detections by:
/// 1. Undistorting each pixel using ground truth K and distortion
/// 2. Computing both undistorted normalized and pixel coordinates
/// 3. Sorting corners by (i, j) grid index
///
/// # Arguments
/// * `detections` - Raw corner detections from calibration pattern
/// * `intrinsics` - Ground truth camera intrinsics
/// * `distortion` - Ground truth distortion model
///
/// # Returns
/// Vector of `CornerInfo` structs sorted by grid indices.
///
/// # Note
/// This function is intended for testing algorithms that assume undistorted
/// inputs. Real-world calibration should not require ground truth distortion.