# Comparison Framework

## Selected Framework Type
Problem Diagnosis + Decision Support

## Identified Weak Points

| # | Category | Component | Severity | Description |
|---|----------|-----------|----------|-------------|
| WP-1 | Functional | Image Preprocessor | Moderate | No explicit lens undistortion using camera calibration matrix K and distortion coefficients |
| WP-2 | Functional | Visual Odometry | Moderate | No camera tilt compensation in GSD calculation. At turn angles 10-30°, GSD error 1.5-15.5% |
| WP-3 | Performance | Satellite Coarse Retrieval | Moderate | DINOv2 uses simple average pooling instead of SALAD/GeM. Missing +12pp retrieval recall improvement |
| WP-4 | Functional | Pipeline Architecture | Low | Draft claims VO/satellite "overlap" on single GPU, which is physically impossible for compute-bound models |
| WP-5 | Security | Dependencies | Critical | python-jose unmaintained, multiple CVEs. Must replace with PyJWT |
| WP-6 | Security | Dependencies | High | Pillow ≥11.3.0 vulnerable to CVE-2026-25990. Must upgrade to ≥12.1.1 |
| WP-7 | Security | Dependencies | High | aiohttp has 7 CVEs. Must upgrade to ≥3.13.3 |
| WP-8 | Security | Dependencies | Critical | h11 CVE-2025-43859 (CVSS 9.1, HTTP request smuggling). Must pin h11 ≥0.16.0 |
| WP-9 | Security | Dependencies | High | ONNX Runtime path traversal. Must upgrade to ≥1.24.1 |
| WP-10 | Functional | Factor Graph | Low | ENU coordinates break down beyond 4km. Long flights need UTM or ENU re-centering |
| WP-11 | Performance | Memory | Low | No explicit memory management for 3000-image flights. Rolling window not specified for features |
| WP-12 | Security | Model Weights | Low | safetensors metadata RCE under review. Validate header size limits |

## Weak Point Solutions

### WP-1: Lens Undistortion

| Solution | Approach | Overhead | Impact |
|----------|----------|----------|--------|
| **cv2.undistort() on full image** | Undistort entire image after loading, before downscaling | ~5-10ms per image | Corrects all features uniformly. Simpler. Slightly increases preprocessing time. |
| **cv2.undistortPoints() on keypoints** | Undistort only detected keypoints after feature extraction | <1ms per image | Lower overhead but must be applied consistently everywhere. Risk of inconsistency. |
| **Recommendation** | cv2.undistort() on full image — simpler, more robust, minimal overhead | | |

### WP-2: Camera Tilt GSD Compensation

| Solution | Approach | Overhead | Impact |
|----------|----------|----------|--------|
| **Extract tilt from homography R** | Use existing decomposeHomographyMat R to get pitch/roll. Apply GSD_corrected = GSD_nadir / cos(θ). | ~0ms (data already available) | Corrects GSD during turns (up to 15.5% error). No new computation needed — just use existing R. |
| **Explicit tilt estimation** | Vanishing point analysis or separate tilt estimator | ~20-50ms | Overkill — homography R already provides tilt. |
| **Recommendation** | Extract tilt from existing homography decomposition R matrix. Zero additional cost. | | |

### WP-3: DINOv2 Aggregation Improvement

| Solution | Approach | Overhead | Impact |
|----------|----------|----------|--------|
| **GeM pooling** | Replace average pooling with Generalized Mean pooling | ~0ms (same computation structure) | +20pp R@1 over average pooling. One-line change. |
| **SALAD aggregation** | Optimal transport + Sinkhorn normalization on patch tokens | <3ms per image | +12pp R@1 over GeM. Requires training adapter (30 min). |
| **Recommendation** | Start with GeM (zero risk, zero overhead). Add SALAD later if retrieval recall is insufficient. | | |

### WP-4: GPU Scheduling Clarification

| Solution | Approach | Overhead | Impact |
|----------|----------|----------|--------|
| **Sequential GPU + async Python** | VO runs on GPU first (latency-critical). Satellite matching queued. Async Python dispatches results. | None vs current | Honest throughput model. VO: ~200ms. Satellite: ~250ms. Total per frame: ~450ms sequential on GPU. But satellite results for frame N arrive while processing frame N+2. |
| **Recommendation** | Clarify architecture: sequential GPU execution, async result delivery. No true overlap. | | |

### WP-5-9: Security Dependency Updates

| Package | Old Pin | New Pin | CVE Mitigated |
|---------|---------|---------|---------------|
| python-jose | any | → **PyJWT ≥2.10.0** | DER confusion, timing attacks, unmaintained |
| Pillow | ≥11.3.0 | → **≥12.1.1** | CVE-2026-25990 |
| aiohttp | unversioned | → **≥3.13.3** | 7 CVEs (DoS, smuggling) |
| h11 | unversioned | → **≥0.16.0** | CVE-2025-43859 (CVSS 9.1) |
| ONNX Runtime | unversioned | → **≥1.24.1** | AIKIDO-2026-10185 (path traversal) |

### WP-10: ENU Coordinate System for Long Flights

| Solution | Approach | Overhead | Impact |
|----------|----------|----------|--------|
| **UTM coordinates** | Use pyproj UTM projection instead of ENU. Zone auto-selected based on starting GPS. | ~negligible | Accurate for flights up to 360km (half UTM zone width). No re-centering needed. |
| **ENU re-centering** | Re-center ENU origin every 3km along the route. Transform between local frames. | Moderate complexity | Maintains accuracy but adds bookkeeping for frame transforms. |
| **Recommendation** | Use UTM. Simpler than re-centering, handles any realistic flight range. pyproj already needed for WGS84↔metric conversion. | | |

### WP-11: Memory Management for Long Flights

| Solution | Approach | Overhead | Impact |
|----------|----------|----------|--------|
| **Rolling window for features** | Keep only current + previous frame SuperPoint features in GPU memory. Discard after VO matching. | None | Keeps feature memory constant at ~4MB regardless of flight length. |
| **Factor graph is already incremental** | iSAM2 stores internal Bayes tree. Memory grows linearly but slowly (~100 bytes/node). 3000 nodes ≈ 300KB. | None | No issue. |
| **SSE ring buffer** | Already specified (1000 events). No change needed. | None | No issue. |
| **DINOv2 embedding cache** | Cache grows with tile count. ~3MB for 2000 tiles. Cap if needed. | None | No issue for realistic flights. |
| **Recommendation** | Add explicit rolling window for SuperPoint features (free after VO matching). Document memory budget. | | |

### WP-12: safetensors Metadata Validation

| Solution | Approach | Overhead | Impact |
|----------|----------|----------|--------|
| **Header size limit** | Validate safetensors header size < 10MB before parsing. Reject oversized headers. | <1ms | Mitigates header-bomb attack vector. |
| **Recommendation** | Add header size validation when loading safetensors files. | | |
