From 2d92c8d8846ad77a9a0385afec0432563c970ad1 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Mon, 10 May 2021 08:24:39 +0800 Subject: update --- tools/misc/ocr | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 tools/misc/ocr (limited to 'tools/misc/ocr') diff --git a/tools/misc/ocr b/tools/misc/ocr new file mode 100755 index 0000000..26594fe --- /dev/null +++ b/tools/misc/ocr @@ -0,0 +1,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 -- cgit v1.2.3-70-g09d2