registration¶
occulus.registration
¶
Point cloud registration — alignment of multiple scans.
Primary interface::
from occulus.registration import icp, ransac_registration, RegistrationResult
from occulus.registration import align_scans, compute_fpfh
Algorithms
- :func:
icp— point-to-point or point-to-plane ICP (auto-selects based on normals) - :func:
icp_point_to_point— explicit point-to-point ICP - :func:
icp_point_to_plane— explicit point-to-plane ICP (requires target normals) - :func:
compute_fpfh— 33-dim FPFH feature descriptors for global registration - :func:
ransac_registration— feature-matching + RANSAC global alignment - :func:
align_scans— sequential multi-scan alignment
AlignmentResult
¶
Result of multi-scan alignment.
Attributes:
| Name | Type | Description |
|---|---|---|
transformations |
list[NDArray[float64]]
|
List of 4×4 transformations, one per input cloud. The first cloud's transformation is always the identity (it is the reference). |
pairwise_results |
list[RegistrationResult]
|
Pairwise registration results between consecutive scans. |
global_rmse |
float
|
Mean inlier RMSE across all pairwise registrations. |
Source code in src/occulus/registration/global_registration.py
RegistrationResult
dataclass
¶
Result of an ICP or global registration.
Attributes:
| Name | Type | Description |
|---|---|---|
transformation |
NDArray[float64]
|
4×4 rigid transformation matrix (source → target frame). |
fitness |
float
|
Fraction of source points with a correspondence within
|
inlier_rmse |
float
|
Root-mean-square error of inlier correspondences (in coordinate units). |
converged |
bool
|
Whether the algorithm met its convergence criterion. |
n_iterations |
int
|
Number of iterations actually performed. |
Source code in src/occulus/registration/icp.py
align_scans(clouds, *, voxel_size=0.5, refine_with_icp=True, max_correspondence_distance=1.0)
¶
Align multiple scans into a common coordinate system.
Performs sequential pairwise ICP registration — each scan is aligned to the previous one. The first cloud is the reference (identity transform).
For best results, pre-process clouds with
:func:~occulus.filters.voxel_downsample and
:func:~occulus.normals.estimate_normals before calling this function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
clouds
|
list[PointCloud]
|
At least 2 PointCloud objects to align. The first cloud is the fixed reference. |
required |
voxel_size
|
float
|
Voxel size used for temporary downsampling before feature-based coarse alignment, by default 0.5. |
0.5
|
refine_with_icp
|
bool
|
Whether to run ICP after coarse alignment, by default |
True
|
max_correspondence_distance
|
float
|
Maximum correspondence distance for ICP refinement, by default 1.0. |
1.0
|
Returns:
| Type | Description |
|---|---|
AlignmentResult
|
Per-cloud transformations and pairwise quality metrics. |
Raises:
| Type | Description |
|---|---|
OcculusRegistrationError
|
If fewer than 2 clouds are provided. |
Source code in src/occulus/registration/global_registration.py
compute_fpfh(cloud, radius, *, max_nn=100)
¶
Compute Fast Point Feature Histogram (FPFH) descriptors.
FPFH is a 33-dimensional descriptor that encodes the local geometry around each point using angular features derived from surface normals. Requires normals on the input cloud.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cloud
|
PointCloud
|
Input cloud. Must have normals ( |
required |
radius
|
float
|
Neighbourhood search radius for feature computation. |
required |
max_nn
|
int
|
Maximum number of neighbours per point, by default 100. |
100
|
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
FPFH descriptor array of shape (N, 33). |
Raises:
| Type | Description |
|---|---|
OcculusValidationError
|
If the cloud has no normals. |
Source code in src/occulus/registration/global_registration.py
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 | |
icp_point_to_plane(source, target, *, max_correspondence_distance=1.0, max_iterations=50, tolerance=1e-06, init_transform=None)
¶
Point-to-plane ICP registration.
Minimises the sum of squared distances projected onto target surface normals. Requires normals on the target cloud. Typically converges faster and with better accuracy than point-to-point near the solution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
PointCloud
|
Source cloud to be transformed. |
required |
target
|
PointCloud
|
Target cloud with normals (fixed reference). |
required |
max_correspondence_distance
|
float
|
Maximum distance for a pair to be a valid correspondence. |
1.0
|
max_iterations
|
int
|
Maximum ICP iterations. |
50
|
tolerance
|
float
|
Convergence tolerance on transformation change. |
1e-06
|
init_transform
|
NDArray[float64] | None
|
Initial 4×4 transformation guess. |
None
|
Returns:
| Type | Description |
|---|---|
RegistrationResult
|
Registration result. |
Raises:
| Type | Description |
|---|---|
OcculusValidationError
|
If target cloud does not have normals. |
OcculusRegistrationError
|
If too few correspondences are found. |
Source code in src/occulus/registration/icp.py
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 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
icp_point_to_point(source, target, *, max_correspondence_distance=1.0, max_iterations=50, tolerance=1e-06, init_transform=None)
¶
Point-to-point ICP registration using SVD.
Minimises the sum of squared Euclidean distances between each source point and its closest target point. The optimal rigid transformation is solved analytically via Singular Value Decomposition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
PointCloud
|
Source cloud to be transformed. |
required |
target
|
PointCloud
|
Target cloud (fixed reference). |
required |
max_correspondence_distance
|
float
|
Maximum distance for a pair to be a valid correspondence. |
1.0
|
max_iterations
|
int
|
Maximum ICP iterations. |
50
|
tolerance
|
float
|
Convergence tolerance on transformation change. |
1e-06
|
init_transform
|
NDArray[float64] | None
|
Initial 4×4 transformation guess. |
None
|
Returns:
| Type | Description |
|---|---|
RegistrationResult
|
Registration result. |
Raises:
| Type | Description |
|---|---|
OcculusRegistrationError
|
If too few correspondences are found to compute a transformation. |
Source code in src/occulus/registration/icp.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 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 | |
ransac_registration(source, target, source_features, target_features, *, max_correspondence_distance=1.5, ransac_n=3, max_iterations=100000, confidence=0.999)
¶
Global registration via feature-matching and RANSAC.
Matches FPFH descriptors between source and target to find feature correspondences, then uses RANSAC to robustly estimate the rigid transformation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
PointCloud
|
Source cloud. |
required |
target
|
PointCloud
|
Target cloud. |
required |
source_features
|
NDArray[float64]
|
FPFH descriptors for source cloud (N, 33). |
required |
target_features
|
NDArray[float64]
|
FPFH descriptors for target cloud (M, 33). |
required |
max_correspondence_distance
|
float
|
Maximum Euclidean distance for an inlier correspondence, by default 1.5. |
1.5
|
ransac_n
|
int
|
Number of random correspondences per RANSAC hypothesis, by default 3. |
3
|
max_iterations
|
int
|
Maximum RANSAC iterations, by default 100_000. |
100000
|
confidence
|
float
|
Desired success probability for RANSAC, used for adaptive early exit, by default 0.999. |
0.999
|
Returns:
| Type | Description |
|---|---|
RegistrationResult
|
Best transformation found. |
Raises:
| Type | Description |
|---|---|
OcculusValidationError
|
If feature array shapes do not match their clouds. |
OcculusRegistrationError
|
If no valid transformation is found. |
Source code in src/occulus/registration/global_registration.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 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 299 300 | |