-
Notifications
You must be signed in to change notification settings - Fork 1
/
importer.sh
executable file
·33 lines (25 loc) · 1.01 KB
/
importer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# Script that imports receipts, runs some image preprocessing
# and runs a text recognition tool afterwards.
# Path to scanned receipts on my USB stick. Please adjust.
RECEIPT_SOURCE="/home/ashu/fuzzy_project/IMG*"
RECEIPT_DEST="img"
#TODO: ENABLE COPY
#cp ${RECEIPT_SOURCE} ${RECEIPT_DEST}
mkdir -p txt
mkdir -p rotated
mkdir -p preprocessed
for receipt in ${RECEIPT_DEST}/*
do
echo "Rotating $receipt..."
receipt_rotated_name="rotated/$(basename $receipt)"
convert -rotate 90 "$receipt" "$receipt_rotated_name"
echo "Image preprocessing..."
receipt_preprocessed_name="preprocessed/$(basename $receipt)"
convert -auto-level -sharpen 0x4.0 -contrast "$receipt_rotated_name" "$receipt_preprocessed_name"
echo "OCR text recognition..."
receipt_txt_name="txt/$(basename $receipt)"
tesseract -l en "$receipt_preprocessed_name" $receipt_txt_name
# TODO: Increase Gamma for non-detected images
#convert -auto-gamma -sharpen 0x4.0 -contrast "$receipt_rotated_name" "$receipt_preprocessed_name"
done