|
#!/bin/bash |
|
|
|
|
|
BATCH_SIZE=30 |
|
COUNTER=0 |
|
OUTPUT_DIR="batches" |
|
RESULTS_FILE="ocr_results.txt" |
|
|
|
|
|
mkdir -p "$OUTPUT_DIR" |
|
|
|
|
|
: > "$RESULTS_FILE" |
|
|
|
|
|
for FILE in output-*.png; do |
|
|
|
BATCH_FILES+=("$FILE") |
|
COUNTER=$((COUNTER + 1)) |
|
|
|
|
|
if (( COUNTER % BATCH_SIZE == 0 || COUNTER == $(ls output-*.png | wc -l) )); then |
|
|
|
BATCH_NAME="${OUTPUT_DIR}/batch_$((COUNTER / BATCH_SIZE)).png" |
|
|
|
|
|
ffmpeg -y -i "concat:$(printf '%s|' "${BATCH_FILES[@]}" | sed 's/|$//')" -vf vstack "$BATCH_NAME" |
|
|
|
|
|
echo "Processing $BATCH_NAME..." |
|
easyocr -l en -f "$BATCH_NAME" --gpu True >> "$RESULTS_FILE" |
|
|
|
|
|
BATCH_FILES=() |
|
fi |
|
done |
|
|
|
echo "OCR processing complete. Results saved to $RESULTS_FILE." |
|
|