feat: Orientierungserkennung in OCR-Pipeline-Deskew integrieren
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 38s
CI / test-go-edu-search (push) Successful in 28s
CI / test-python-klausur (push) Failing after 1m59s
CI / test-python-agent-core (push) Successful in 16s
CI / test-nodejs-website (push) Successful in 21s
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 38s
CI / test-go-edu-search (push) Successful in 28s
CI / test-python-klausur (push) Failing after 1m59s
CI / test-python-agent-core (push) Successful in 16s
CI / test-nodejs-website (push) Successful in 21s
detect_and_fix_orientation() wird jetzt vor dem Deskew-Schritt in der OCR-Pipeline ausgefuehrt, sodass 90/180/270°-gedrehte Scans automatisch korrigiert werden. Frontend zeigt Orientierungskorrektur als Info-Banner. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -85,6 +85,7 @@ export interface DeskewResult {
|
||||
angle_applied: number
|
||||
method_used: 'hough' | 'word_alignment' | 'manual' | 'iterative' | 'two_pass' | 'three_pass' | 'manual_combined'
|
||||
confidence: number
|
||||
orientation_degrees?: number
|
||||
duration_seconds: number
|
||||
deskewed_image_url: string
|
||||
binarized_image_url: string
|
||||
|
||||
@@ -59,6 +59,11 @@ export function DeskewControls({
|
||||
{/* Results */}
|
||||
{deskewResult && (
|
||||
<div className="bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4">
|
||||
{deskewResult.orientation_degrees ? (
|
||||
<div className="flex items-center gap-2 mb-2 px-2 py-1 bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-400 rounded text-xs">
|
||||
Seite wurde um {deskewResult.orientation_degrees}° gedreht (Orientierungskorrektur)
|
||||
</div>
|
||||
) : null}
|
||||
<div className="flex flex-wrap items-center gap-3 text-sm">
|
||||
<div>
|
||||
<span className="text-gray-500">Winkel:</span>{' '}
|
||||
|
||||
@@ -54,6 +54,7 @@ from cv_vocab_pipeline import (
|
||||
deskew_image_by_word_alignment,
|
||||
deskew_image_iterative,
|
||||
deskew_two_pass,
|
||||
detect_and_fix_orientation,
|
||||
detect_column_geometry,
|
||||
detect_document_type,
|
||||
detect_row_geometry,
|
||||
@@ -475,6 +476,16 @@ async def auto_deskew(session_id: str):
|
||||
|
||||
t0 = time.time()
|
||||
|
||||
# Orientation detection (fix 90/180/270° rotations from scanners)
|
||||
img_bgr, orientation_deg = detect_and_fix_orientation(img_bgr)
|
||||
if orientation_deg:
|
||||
# Update original in cache + DB so all subsequent steps use corrected image
|
||||
cached["original_bgr"] = img_bgr
|
||||
success_ori, ori_buf = cv2.imencode(".png", img_bgr)
|
||||
if success_ori:
|
||||
await update_session_db(session_id, original_png=ori_buf.tobytes())
|
||||
logger.info(f"OCR Pipeline: orientation corrected {orientation_deg}° for session {session_id}")
|
||||
|
||||
# Two-pass deskew: iterative (±5°) + word-alignment residual check
|
||||
deskewed_bgr, angle_applied, two_pass_debug = deskew_two_pass(img_bgr.copy())
|
||||
|
||||
@@ -523,6 +534,7 @@ async def auto_deskew(session_id: str):
|
||||
"angle_residual": round(angle_residual, 3),
|
||||
"angle_textline": round(angle_textline, 3),
|
||||
"angle_applied": round(angle_applied, 3),
|
||||
"orientation_degrees": orientation_deg,
|
||||
"method_used": method_used,
|
||||
"confidence": round(confidence, 2),
|
||||
"duration_seconds": round(duration, 2),
|
||||
@@ -551,6 +563,7 @@ async def auto_deskew(session_id: str):
|
||||
f"-> {method_used} total={angle_applied:.2f}")
|
||||
|
||||
await _append_pipeline_log(session_id, "deskew", {
|
||||
"orientation": orientation_deg,
|
||||
"angle_applied": round(angle_applied, 3),
|
||||
"angle_iterative": round(angle_iterative, 3),
|
||||
"angle_residual": round(angle_residual, 3),
|
||||
|
||||
Reference in New Issue
Block a user