ds_msp.ldc¶
Lens-distortion-correction mesh export — for embedded/ISP undistortion pipelines that need a precomputed remap mesh rather than a per-frame closed-form call. See Export an LDC mesh.
ds_msp.ldc ¶
Texas Instruments (TI) Jacinto LDC displacement-mesh export.
Generates a quantized displacement-mesh lookup table for the on-chip Lens
Distortion Correction (LDC) hardware accelerator on TI Jacinto J7/TDA4 SoCs,
from a calibrated :class:~ds_msp.model.DoubleSphereCamera, plus a point
undistorter that simulates the hardware's own mesh-inversion behavior. See
Export a TI Jacinto LDC displacement mesh.
TI_LDC_MeshGenerator ¶
Texas Instruments (TI) Lens Distortion Correction (LDC) Mesh LUT Generator.
Generates downsampled displacement mesh lookup tables compatible with
TI Jacinto J7/TDA4 hardware accelerators, from a calibrated
:class:~ds_msp.model.DoubleSphereCamera. See
Export a TI Jacinto LDC displacement mesh
for a worked example with real mesh numbers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds_camera
|
DoubleSphereCamera
|
The calibrated fisheye camera to generate a mesh for. Its
|
required |
Source code in ds_msp/ldc.py
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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
generate_mesh_and_intrinsics ¶
generate_mesh_and_intrinsics(output_width: int, output_height: int, downsample_factor: int = 4, balance: float = 0.5) -> Dict
Generate the LDC displacement mesh (Q3 fixed point) and rectified intrinsics.
Samples one mesh node every 2**downsample_factor output pixels (plus a
one-node border), computing at each node the pixel displacement between
the undistorted (pinhole) location and its Double Sphere-distorted
source location, quantized to Q3 fixed point (round(delta_px * 8),
int16).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_width
|
int
|
Size of the undistorted (on-chip output) image, pixels. Independent
of |
required |
output_height
|
int
|
Size of the undistorted (on-chip output) image, pixels. Independent
of |
required |
downsample_factor
|
int
|
Power-of-two mesh node spacing: nodes are sampled every
|
4
|
balance
|
float
|
Field-of-view/border trade-off in |
0.5
|
Returns:
| Type | Description |
|---|---|
dict
|
With keys:
|
Notes
Overflow of the int16 Q3 range ([-32768, 32767]) is not
checked or raised here — a large enough field of view produces
displacements that silently wrap to the wrong sign. Inspect
mesh_lut.min()/.max() after generation, especially for
aggressive fields of view (see the how-to guide's Warning).
Source code in ds_msp/ldc.py
TI_LDC_PointUndistorter ¶
Simulates TI J7 LDC hardware displacement interpolation to undistort points.
Inverts a mesh produced by :meth:TI_LDC_MeshGenerator.generate_mesh_and_intrinsics
to recover undistorted (pinhole) coordinates for distorted input pixels, by the
same bilinear-interpolation + fixed-point-iteration approach the LDC hardware
itself performs. Prefer the closed-form
:meth:~ds_msp.model.DoubleSphereCamera.undistort_points for anything other
than reproducing hardware behavior — the mesh inverse is exact only near the
image center and diverges sharply toward the periphery (measured ~0.08 px
median disagreement overall, ~80 px at the corners in a representative
1920x1080 configuration; see
Export a TI Jacinto LDC displacement mesh).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh_lut_float
|
ndarray of shape (mesh_h, mesh_w, 2), float64
|
The unquantized displacement mesh, i.e. |
required |
K_new
|
ndarray of shape (3, 3)
|
The rectified pinhole intrinsics the mesh was generated for (same
|
required |
downsample_factor
|
int
|
The power-of-two mesh node spacing used to generate |
required |
output_width
|
int
|
Size of the undistorted (output) image the mesh targets. |
required |
output_height
|
int
|
Size of the undistorted (output) image the mesh targets. |
required |
Source code in ds_msp/ldc.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
undistort_points ¶
Invert the LDC displacement mesh for a batch of distorted points.
Fully vectorized fixed-point solve: every point iterates together, and a point drops out of the active set once it converges (residual < 0.01 px) or its current estimate leaves the mesh. Equivalent to the per-point Newton-free iteration the J7 LDC performs, but array-wide. Runs at most 10 iterations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points_distorted
|
ndarray of shape (N, 2)
|
Distorted pixel coordinates in the original fisheye image. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
guess |
ndarray of shape (N, 2)
|
Estimated undistorted (pinhole, |
valid |
ndarray of shape (N,), bool
|
|