added status, better date and time and some processing
This commit is contained in:
parent
8979b754dd
commit
9e7bd54b1f
15
ocr.sh
15
ocr.sh
@ -1,18 +1,20 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
INPUT_IMAGE=$1
|
INPUT_IMAGE=$1
|
||||||
|
|
||||||
raw_text=$(tesseract $INPUT_IMAGE stdout)
|
raw_text=$(tesseract $INPUT_IMAGE stdout --psm 6)
|
||||||
|
|
||||||
referece=$(echo "$raw_text" | grep -o 'BLAZ[0-9]*')
|
referece=$(echo "$raw_text" | grep -o 'BLAZ[0-9]*')
|
||||||
to_number=$(echo "$raw_text" | grep -oE '\b9[0-9]{16}\b|\b7[0-9]{12}\b')
|
to_number=$(echo "$raw_text" | grep -oE '\b9[0-9]{16}\b|\b7[0-9]{12}\b')
|
||||||
date=$(echo "$raw_text" | grep -oE '\b[0-3][0-9]/[0-1][0-9]/[0-9]{4}\b')
|
#date=$(echo "$raw_text" | grep -oE '\b[0-3][0-9]/[0-1][0-9]/[0-9]{4}\b')
|
||||||
time=$(echo "$raw_text" | grep -oE '\b[0-2][0-9]:[0-5][0-9]\b')
|
#time=$(echo "$raw_text" | grep -oE '\b[0-2][0-9]:[0-5][0-9]\b')
|
||||||
|
date=$(echo "$raw_text" | grep -oE '[0-3][0-9]/[0-1][0-9]/[0-9]{4}')
|
||||||
|
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]+')
|
||||||
|
|
||||||
json_output=$(cat <<EOF
|
json=$(cat <<EOF
|
||||||
{
|
{
|
||||||
"Amount": "$amount",
|
"Amount": "$amount",
|
||||||
"Currency": "$currency",
|
"Currency": "$currency",
|
||||||
@ -30,4 +32,5 @@ json_output=$(cat <<EOF
|
|||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
echo $json_output
|
echo $json | jq
|
||||||
|
echo $raw_text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user