#!/usr/bin/env bash # Test-only tool: runs preprocessing + OCR (1_preprocess_image.sh, # 2_ocr_image.sh - variant 0/baseline only, deliberately not # 12_adaptive_preprocess_ocr.sh) on a single receipt photo and prints the # raw OCR text to stdout - no LLM extraction step, no ground-truth # comparison, and no files left behind (unlike test_single.sh/ # test_batch.sh, which persist scratch/result directories and go through # the real adaptive pipeline). Useful for quickly checking what Tesseract # actually reads off one specific preprocessing variant in isolation - # e.g. while iterating on tooling-container/src/preprocess.py - without # the adaptive step's variant selection in the way, waiting on the LLM # call, or needing ground truth. # # Usage: ./test_ocr.sh -in set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" fail() { echo "FAIL: $*" >&2; exit 1; } IN_PATH="" while [ $# -gt 0 ]; do case "$1" in -in) IN_PATH="${2:-}"; shift 2 ;; *) fail "unknown argument: $1" ;; esac done [ -n "$IN_PATH" ] || fail "usage: $0 -in " [ -f "$IN_PATH" ] || fail "input file not found: $IN_PATH" SCRATCH_DIR="$(mktemp -d)" trap 'rm -rf "$SCRATCH_DIR"' EXIT ./1_preprocess_image.sh -in "$IN_PATH" -out "$SCRATCH_DIR" >/dev/null ./2_ocr_image.sh -in "$SCRATCH_DIR/03_final.png" -out "$SCRATCH_DIR" >/dev/null cat "$SCRATCH_DIR/ocr.txt"