added experimental from and to_name

This commit is contained in:
Shihaam Abdul Rahman 2024-08-03 02:15:17 +05:00
parent 115313ce3a
commit f9ef381c90
Signed by: shihaam
GPG Key ID: 6DA2E87EBC227636
2 changed files with 6 additions and 2 deletions

4
ocr.sh
View File

@ -14,6 +14,8 @@ currency=$(echo "$raw_text" | grep -oP '(?<=Amount\s)[A-Z]{3}')
amount=$(echo "$raw_text" | grep -oP '(?<=Amount\s[A-Z]{3}\s)[0-9]{1,3}(?:,[0-9]{3})*(?:\.[0-9]{2})') amount=$(echo "$raw_text" | grep -oP '(?<=Amount\s[A-Z]{3}\s)[0-9]{1,3}(?:,[0-9]{3})*(?:\.[0-9]{2})')
status=$(echo "$raw_text" | grep -oP '(?<=Status\s)[A-Z]+') status=$(echo "$raw_text" | grep -oP '(?<=Status\s)[A-Z]+')
remarks=$(echo "$raw_text" | grep Remarks | sed 's/Remarks //') remarks=$(echo "$raw_text" | grep Remarks | sed 's/Remarks //')
from=$(echo "$raw_text" | grep From | sed 's/From //')
to_name=$(echo "$raw_text"| grep -B1 $to_number | grep -v $to_number)
json=$(cat <<EOF json=$(cat <<EOF
{ {
@ -34,4 +36,4 @@ EOF
echo $json | jq echo $json | jq
#echo $raw_text #echo $raw_text
tesseract $INPUT_IMAGE stdout --psm 6 #tesseract $INPUT_IMAGE stdout --psm 6

View File

@ -23,7 +23,9 @@ time=$(echo "$raw_text" | grep -oE '[0-2][0-9]:[0-5][0-9]')
currency=$(echo "$raw_text" | grep -oP '(?<=Amount\s)[A-Z]{3}') currency=$(echo "$raw_text" | grep -oP '(?<=Amount\s)[A-Z]{3}')
amount=$(echo "$raw_text" | grep -oP '(?<=Amount\s[A-Z]{3}\s)[0-9]{1,3}(?:,[0-9]{3})*(?:\.[0-9]{2})') amount=$(echo "$raw_text" | grep -oP '(?<=Amount\s[A-Z]{3}\s)[0-9]{1,3}(?:,[0-9]{3})*(?:\.[0-9]{2})')
status=$(echo "$raw_text" | grep -oP '(?<=Status\s)[A-Z]+') status=$(echo "$raw_text" | grep -oP '(?<=Status\s)[A-Z]+')
from=$(echo "$raw_text" | grep -oP '(?<=From\s)[A-Z\s]+(?=\s[A-Z][a-z])') remarks=$(echo "$raw_text" | grep Remarks | sed 's/Remarks //')
from=$(echo "$raw_text" | grep From | sed 's/From //')
to_name=$(echo "$raw_text"| grep -B1 $to_number | grep -v $to_number)
json=$(cat <<EOF json=$(cat <<EOF
{ {