summaryrefslogtreecommitdiffstats
path: root/local/bin
diff options
context:
space:
mode:
Diffstat (limited to 'local/bin')
-rwxr-xr-xlocal/bin/screenshot_ocr.sh16
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.