diff options
| author | Mitsuo Tokumori <[email protected]> | 2024-08-29 03:42:11 +0900 |
|---|---|---|
| committer | Mitsuo Tokumori <[email protected]> | 2024-08-29 03:42:11 +0900 |
| commit | 70b1939ef489da8cc169b23a2467bfbab8994a52 (patch) | |
| tree | 8e77a185e434153bfe561339936d48b8fe63ef7a /local | |
| parent | 5f47923b7ede266a631deec5511bb58444e3fab4 (diff) | |
| download | dotfiles-70b1939ef489da8cc169b23a2467bfbab8994a52.tar.gz dotfiles-70b1939ef489da8cc169b23a2467bfbab8994a52.tar.bz2 dotfiles-70b1939ef489da8cc169b23a2467bfbab8994a52.zip | |
Add suppport for QR codes to screenshot OCR tool
Diffstat (limited to 'local')
| -rwxr-xr-x | local/bin/screenshot_ocr.sh | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/local/bin/screenshot_ocr.sh b/local/bin/screenshot_ocr.sh index de84d93..d88accf 100755 --- a/local/bin/screenshot_ocr.sh +++ b/local/bin/screenshot_ocr.sh @@ -4,20 +4,26 @@ savepath="/tmp/screenshot_ocr.sh.d" filename="$HOSTNAME-$(date -Iseconds | tr -d ':-').png" -tesseract_options="-l eng" +# German: deu, Spanish: spa, Japanese vertical: jpn_vert +tesseract_options="-l eng+jpn" _init() { if [ ! -d "$savepath" ]; then mkdir -p "$savepath" fi - cd /tmp/screenshot_ocr.sh.d + cd "$savepath" } _init -# screenshot region of screen +# Screenshot region of screen shotgun -g $(hacksaw) "$filename" -# exit if previous command was unsuccessful +# Exit if previous command was unsuccessful test $? -ne 0 && exit -# perform OCR and save to clipboard +# Try to scan codes from the image +zbarimg $filename | xclip -selection "clipboard" +# Perform OCR and save to clipboard tesseract $tesseract_options $filename - | xclip -selection "clipboard" rm $filename + +# TODO: clean japanese output. If text is 80% japanese characters, then it +# should not contain spaces around the characters. |
