diff options
Diffstat (limited to 'bin/misc/ocr')
-rwxr-xr-x | bin/misc/ocr | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/misc/ocr b/bin/misc/ocr new file mode 100755 index 0000000..26594fe --- /dev/null +++ b/bin/misc/ocr | |||
@@ -0,0 +1,16 @@ | |||
1 | #!/bin/bash | ||
2 | # Dependencies: tesseract-ocr imagemagick scrot xsel | ||
3 | |||
4 | SCR_IMG=`mktemp` | ||
5 | trap "rm $SCR_IMG*" EXIT | ||
6 | |||
7 | scrot -s $SCR_IMG.png -q 100 | ||
8 | # increase image quality with option -q from default 75 to 100 | ||
9 | |||
10 | mogrify -modulate 100,0 -resize 400% $SCR_IMG.png | ||
11 | #should increase detection rate | ||
12 | |||
13 | tesseract $SCR_IMG.png $SCR_IMG &> /dev/null | ||
14 | cat $SCR_IMG.txt | trans -t zh-TW --brief --engine bing | cat $SCR_IMG.txt - | tr '\n' ' ' | xargs -I{} notify-send --urgency=critical translation '{}' | ||
15 | |||
16 | exit | ||