Metadata-Version: 2.4
Name: optocalib-lab
Version: 0.5.5
Summary: ArUco-locked perspective alignment with CIE Lab / CIEDE2000 calibration, 16-bit linear RAW, and optional Numba acceleration.
Project-URL: Homepage, https://github.com
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: numpy
Requires-Dist: opencv-contrib-python-headless
Provides-Extra: raw
Requires-Dist: rawpy; extra == "raw"
Provides-Extra: fast
Requires-Dist: numba; extra == "fast"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: rawpy; extra == "dev"
Requires-Dist: numba; extra == "dev"

# OptoCalib

<p align="center">
  <img src="https://githubusercontent.com" alt="OptoCalib Before and After Calibration" width="100%">
</p>

*ArUco-locked perspective alignment with perceptual CIE L\*a\*b\* / CIEDE2000 colorimetry, 16-bit linear RAW processing, Ridge-regularized 3×3 CCM, and Numba-accelerated post-detect warping.*

```bash
pip install optocalib-lab
```

## Key Features (`v0.5.5`)
- **Perspective & Scale Rectification:** Locks onto 4 ArUco markers (`IDs 0-3`) with sub-pixel corner refinement (`cv2.cornerSubPix`).
- **Perceptual Colorimetry (`CIEDE2000 / ΔE₀₀`):** Normalizes ambient illuminant shift using a white reference ROI and reports perceptual color error verified against the Sharma et al. (2005) reference dataset.
- **16-Bit Linear RAW & `3×3` CCM:** Supports linear sensor arrays, Ridge-regularized `3×3` Color Correction Matrix fitting, and HSV specular glare masking.
- **Typed API & Uncertainty (`PEP 561`):** Immutable `CalibrationResult` dataclasses, domain exceptions (`MarkersNotFound`, `InvalidRawLevels`), `95%` bootstrap confidence intervals (`CV%`), and CLI (`python -m optocalib.cli`).

## Quick Start

```python
import cv2
from optocalib import generate_calibration_card, calibrate_typed

# 1. Generate a printable calibration template
generate_calibration_card("my_lab_mat.png")

# 2. Rectify perspective and normalize ambient lighting
bgr = cv2.imread("captured_photo.jpg")
result = calibrate_typed(bgr, strict=True)
print(f"ΔE00: {result.delta_e00_before:.2f} -> {result.delta_e00_after:.2f} ({result.backend})")
cv2.imwrite("calibrated_output.png", result.image)
```

## Latency Benchmark & Reproducibility
Post-detect homography warp + white-balance fusion benchmark (`820×360` BGR `uint8` frame, `50` timed repeats after `5` JIT warm-up runs on Apple Silicon M-series CPU):

| Backend | Resolution | Warm-up | Timed Repeats | Median Latency |
| :--- | :--- | :--- | :--- | :--- |
| **Numba JIT (`numba`)** | `820 × 360` | 5 | 50 | **~0.57 ms** |
| **Pure NumPy Fallback** | `820 × 360` | 5 | 50 | ~3.40 ms |

## Development & Attribution
OptoCalib was architected, specified, and verified by **Bedriye Dilmen** (`b-dlmnnn`), combining OpenCV/NumPy computer-vision primitives with perceptual CIEDE2000 colorimetry, 16-bit linear sensor processing, Ridge-regularized `3×3` CCM fitting, and bootstrap uncertainty intervals. AI coding assistants were used during implementation and refactoring; all mathematical invariants and `87` unit tests were audited and verified locally.
