fix: always include detections in dewarp response, even when no correction applied
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 28s
CI / test-go-edu-search (push) Successful in 25s
CI / test-python-klausur (push) Failing after 1m49s
CI / test-python-agent-core (push) Successful in 15s
CI / test-nodejs-website (push) Successful in 19s

The detections array was empty when shear was below threshold, hiding
all 4 method results from the frontend Details panel.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-03-04 09:05:43 +01:00
parent c484a89b78
commit 0d3f001acb

View File

@@ -903,8 +903,16 @@ def dewarp_image(img: np.ndarray, use_ensemble: bool = True) -> Tuple[np.ndarray
detections[3]["confidence"] if len(detections) > 3 else 0.0,
)
# Always include individual detections (even when no correction applied)
_all_detections = [
{"method": d["method"], "shear_degrees": d["shear_degrees"],
"confidence": d["confidence"]}
for d in detections
]
# Higher thresholds: subtle shear (<0.15°) is irrelevant for OCR
if abs(shear_deg) < 0.15 or confidence < 0.5:
no_correction["detections"] = _all_detections
return img, no_correction
# Apply correction (negate the detected shear to straighten)
@@ -914,22 +922,14 @@ def dewarp_image(img: np.ndarray, use_ensemble: bool = True) -> Tuple[np.ndarray
if not _dewarp_quality_check(img, corrected):
logger.info("dewarp: quality gate REJECTED correction (%.3f°) — "
"projection variance did not improve", shear_deg)
no_correction["detections"] = [
{"method": d["method"], "shear_degrees": d["shear_degrees"],
"confidence": d["confidence"]}
for d in detections
]
no_correction["detections"] = _all_detections
return img, no_correction
info = {
"method": method,
"shear_degrees": shear_deg,
"confidence": confidence,
"detections": [
{"method": d["method"], "shear_degrees": d["shear_degrees"],
"confidence": d["confidence"]}
for d in detections
],
"detections": _all_detections,
}
return corrected, info