aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/misc/ocr
blob: 26594fe184c8a35917fe3de3c3b7f6295f54d65f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash 
# Dependencies: tesseract-ocr imagemagick scrot xsel

SCR_IMG=`mktemp`
trap "rm $SCR_IMG*" EXIT

scrot -s $SCR_IMG.png -q 100    
# increase image quality with option -q from default 75 to 100

mogrify -modulate 100,0 -resize 400% $SCR_IMG.png 
#should increase detection rate

tesseract $SCR_IMG.png $SCR_IMG &> /dev/null
cat $SCR_IMG.txt | trans -t zh-TW --brief --engine bing | cat $SCR_IMG.txt - | tr '\n' ' ' | xargs -I{} notify-send --urgency=critical translation '{}'

exit