Skip to content

Commit 5cbc40d

Browse files
Merge pull request #3 from sashakolpakov/1-add-features-other-than-coordinates
1 add features other than coordinates
2 parents 1fe9390 + 56a0180 commit 5cbc40d

19 files changed

Lines changed: 1748 additions & 865 deletions

.github/workflows/deploy_docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
run: |
3030
cd einit_docs
3131
sphinx-build -b html . _build/html
32-
32+
3333
- name: Deploy to GitHub Pages
3434
uses: peaceiris/actions-gh-pages@v3
3535
if: github.ref == 'refs/heads/main'

.github/workflows/pylint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ jobs:
5252
run: |
5353
pytest einit_tests/test_einit.py -v
5454
pytest einit_tests/test_integration.py -v
55+
pytest einit_tests/test_features.py -v

README.md

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@
3636

3737
- **Fast**: < 1ms for 1000 points
3838
- **Accurate**: Often achieves excellent alignment without iterative refinement
39-
- **OpenCV compatible**: Returns standard 4×4 transformation matrices
39+
- **OpenCV compatible**: Returns standard 4×4 transformation matrices
4040
- **Robust**: Handles noise, partial overlap, and permuted point clouds
4141
- **Permutation invariant**: Results are identical regardless of point ordering
42+
- **Feature-augmented**: Optional per-point features (RGB, intensity, normals) break geometric degeneracy for symmetric shapes
4243
- **Configurable**: Adjustable parameters for different use cases
4344
- **Simple API**: One function call to get results
4445

@@ -60,9 +61,20 @@ print(T) # 4x4 homogeneous transformation matrix
6061
T = register_ellipsoid(
6162
src_points, dst_points,
6263
max_correspondence_distance=0.1, # Maximum distance for valid correspondences
63-
min_inlier_fraction=0.7, # Require 70% valid correspondences
64+
min_inlier_fraction=0.7, # Require 70% valid correspondences
6465
leafsize=8 # Smaller KD-tree leaf size
6566
)
67+
68+
# With per-point features (e.g. RGB colour or LiDAR intensity)
69+
# Features break geometric degeneracy for symmetric shapes (spheres, cubes)
70+
src_rgb = np.random.rand(1000, 3) # RGB colour per point
71+
dst_rgb = np.random.rand(1000, 3)
72+
T = register_ellipsoid(
73+
src_points, dst_points,
74+
src_features=src_rgb,
75+
dst_features=dst_rgb,
76+
feature_weight=1.0 # 0.0 = geometry only; typical range 0.1–1.0
77+
)
6678
```
6779

6880
## Installation
@@ -109,13 +121,21 @@ Real-world performance on test datasets:
109121
The algorithm works by:
110122

111123
1. **Centering** point clouds at their centroids
112-
2. **Computing** ellipsoids of inertia via eigendecomposition
124+
2. **Computing** ellipsoids of inertia via eigendecomposition (optionally augmented with per-point features)
113125
3. **Searching** through 8 reflection combinations using KD-tree correspondence recovery
114126
4. **Filtering** correspondences by distance and inlier fraction
115127
5. **Returning** a 4×4 transformation matrix
116128

117129
KD-tree correspondence recovery makes the algorithm robust to point cloud permutations, partial overlaps, and outliers without assuming that points at the same array indices correspond to each other.
118130

131+
When per-point features are supplied (`src_features`, `dst_features`, `feature_weight > 0`), the spatial covariance is augmented by a spatial-feature cross-covariance term:
132+
133+
```
134+
E_aug = P^T P + feature_weight * trace_ratio * (P^T F)(P^T F)^T
135+
```
136+
137+
This biases the principal axes toward directions where features vary most, breaking eigenvalue degeneracy for symmetric shapes (spheres, cubes, cylinders). The KD-tree step also runs in feature-augmented space so that feature similarity guides nearest-neighbour selection. Features are normalised to keep `feature_weight` dimensionless and dataset-independent.
138+
119139
## OpenCV Integration
120140

121141
```python
@@ -166,25 +186,32 @@ python einit_examples/bbox_overlap_test.py
166186
```
167187
Evaluates performance on the Stanford bunny with geometric bounding box constraints.
168188

169-
> **Note**: Unlike randomized overlaps, this is a known failure mode of the algorithm. Low success rate is expected.
189+
> **Note**: Unlike randomized overlaps, this is a known failure mode of the algorithm. Low success rate is expected.
170190
191+
**Feature Matching Diagnostic:**
192+
```bash
193+
python einit_examples/cube_feature_matching.py
194+
```
195+
Four-panel diagnostic visualisation showing how RGB face colours break the cube's 48-fold geometric symmetry. Produces eigenvalue spectra, per-candidate RMSE/inlier plots, and side-by-side alignment results comparing geometry-only vs feature-augmented registration.
171196

172197
### Running Tests
173198

199+
The `einit_tests/` directory contains comprehensive test suites validating core functionality:
200+
174201
```bash
175202
# All tests
176203
pytest einit_tests/ -v
177204

178-
# Core algorithm tests
179-
pytest einit_tests/test_einit.py -v
180-
181-
# Stanford bunny integration test
182-
pytest einit_tests/test_integration.py -v
205+
# Specific test categories
206+
pytest einit_tests/test_einit.py -v # Core algorithm tests
207+
pytest einit_tests/test_integration.py -v # Integration and robustness tests
208+
pytest einit_tests/test_features.py -v # Feature-augmented benchmarks
183209
```
184210

185211
**Test Coverage:**
186-
- **Core Tests**: Basic functionality, synthetic shapes (spheres, cube surfaces), and Stanford bunny validation
187-
- **Integration Test**: Real-world Stanford bunny PLY dataset with partial overlap and noise
212+
- **Core Algorithm Tests** (`test_einit.py`): Basic functionality, permutation invariance, noise robustness, and Stanford bunny dataset validation
213+
- **Integration Tests** (`test_integration.py`): End-to-end pipeline testing with real-world scenarios
214+
- **Feature Tests** (`test_features.py`): Three real-world feature scenarios (Stanford bunny with LiDAR intensity, hemisphere-flip sphere, coloured cube), a feature-weight sweep, and API-level validation tests
188215

189216
## Documentation
190217

build/.DS_Store

6 KB
Binary file not shown.

dist/einit-0.2.0-py3.8.egg

27.5 KB
Binary file not shown.

einit.egg-info/PKG-INFO

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Metadata-Version: 2.1
2+
Name: einit
3+
Version: 0.1.0
4+
Summary: Ellipsoid ICP initialization for OpenCV-compatible pipelines
5+
Author: Alexander Kolpakov (UATX), Michael Werman (HUJI), Judah Levin (UATX)
6+
Requires-Python: >=3.6
7+
License-File: LICENSE
8+
Requires-Dist: numpy>=1.15
9+
Requires-Dist: scipy>=1.0
10+
Provides-Extra: opencv
11+
Requires-Dist: opencv-python-headless>=3.4; extra == "opencv"
12+
Provides-Extra: test
13+
Requires-Dist: pytest>=6.0; extra == "test"
14+
Requires-Dist: opencv-python-headless>=3.4; extra == "test"
15+
Requires-Dist: matplotlib>=3.0; extra == "test"
16+
Provides-Extra: docs
17+
Requires-Dist: sphinx>=4.0; extra == "docs"
18+
Requires-Dist: sphinx_rtd_theme>=1.0; extra == "docs"
19+
Provides-Extra: all
20+
Requires-Dist: opencv-python-headless>=3.4; extra == "all"
21+
Requires-Dist: pytest>=6.0; extra == "all"
22+
Requires-Dist: matplotlib>=3.0; extra == "all"
23+
Requires-Dist: sphinx>=4.0; extra == "all"
24+
Requires-Dist: sphinx_rtd_theme>=1.0; extra == "all"

einit.egg-info/SOURCES.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
LICENSE
2+
README.md
3+
setup.py
4+
einit/__init__.py
5+
einit/einit.py
6+
einit.egg-info/PKG-INFO
7+
einit.egg-info/SOURCES.txt
8+
einit.egg-info/dependency_links.txt
9+
einit.egg-info/requires.txt
10+
einit.egg-info/top_level.txt
11+
einit_tests/__init__.py
12+
einit_tests/test_einit.py
13+
einit_tests/test_features.py
14+
einit_tests/test_integration.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

einit.egg-info/requires.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
numpy>=1.15
2+
scipy>=1.0
3+
4+
[all]
5+
opencv-python-headless>=3.4
6+
pytest>=6.0
7+
matplotlib>=3.0
8+
sphinx>=4.0
9+
sphinx_rtd_theme>=1.0
10+
11+
[docs]
12+
sphinx>=4.0
13+
sphinx_rtd_theme>=1.0
14+
15+
[opencv]
16+
opencv-python-headless>=3.4
17+
18+
[test]
19+
pytest>=6.0
20+
opencv-python-headless>=3.4
21+
matplotlib>=3.0

einit.egg-info/top_level.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
einit
2+
einit_tests

0 commit comments

Comments
 (0)