fix(ocr-pipeline): dewarp visibility, grid on both sides, session persistence
- Fix dewarp method selection: prefer methods with >5px curvature over
higher confidence (vertical_edge 79px was being ignored for text_baseline 2px)
- Add grid overlay on left image in Dewarp step for side-by-side comparison
- Add GET /sessions/{id} endpoint to reload session data
- StepDeskew accepts sessionId prop to restore state when navigating back
- SessionInfo type extended with optional deskew_result and dewarp_result
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -627,12 +627,24 @@ def dewarp_image(img: np.ndarray) -> Tuple[np.ndarray, Dict[str, Any]]:
|
||||
f"curv={result_b['curvature_px']:.1f}px "
|
||||
f"({duration:.2f}s)")
|
||||
|
||||
# Pick method with higher confidence
|
||||
if result_a["confidence"] >= result_b["confidence"]:
|
||||
# Pick best method: prefer significant curvature over high confidence
|
||||
# If one method found real curvature (>5px) and the other didn't (<3px),
|
||||
# prefer the one with real curvature regardless of confidence.
|
||||
a_has_curvature = result_a["curvature_px"] >= 5.0 and result_a["displacement_map"] is not None
|
||||
b_has_curvature = result_b["curvature_px"] >= 5.0 and result_b["displacement_map"] is not None
|
||||
|
||||
if a_has_curvature and not b_has_curvature:
|
||||
best = result_a
|
||||
elif b_has_curvature and not a_has_curvature:
|
||||
best = result_b
|
||||
elif result_a["confidence"] >= result_b["confidence"]:
|
||||
best = result_a
|
||||
else:
|
||||
best = result_b
|
||||
|
||||
logger.info(f"dewarp: selected {best['method']} "
|
||||
f"(curv={best['curvature_px']:.1f}px, conf={best['confidence']:.2f})")
|
||||
|
||||
if best["displacement_map"] is None or best["curvature_px"] < 2.0:
|
||||
return img, no_correction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user