Belki zaten bunu yapan bir araç var, ancak kullanmaya çalıştığınız gibi bazı ekran görüntüsü aracı ve tesseract ile basit bir betik oluşturabilirsiniz.
Bu komut dosyasını örnek olarak alın (sistemimde /usr/local/bin/screen_ts
olarak kaydettim):
#!/bin/bash
# Dependencies: tesseract-ocr imagemagick scrot
select tesseract_lang in eng rus equ ;do break;done
# Quick language menu, add more if you need other languages.
SCR_IMG='mktemp'
trap "rm $SCR_IMG*" EXIT
scrot -s $SCR_IMG.png -q 100
# increase quality with option -q from default 75 to 100
# Typo "$SCR_IMG.png000" does not continue with same name.
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
exit
Ve pano desteği ile:
#!/bin/bash
# Dependencies: tesseract-ocr imagemagick scrot xsel
select tesseract_lang in eng rus equ ;do break;done
# quick language menu, add more if you need other languages.
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 | xsel -bi
exit
Ekranı almak için scrot
, metni tanımak için tesseract
ve sonucu görüntülemek için cat
değerini kullanır. Pano sürümü ayrıca çıktıyı panoya aktarmak için xsel
kullanır.
NOT : scrot
, xsel
, imagemagick
ve tesseract-ocr
varsayılan olarak yüklenmemiş, ancak varsayılan depolardan edinilebilir.
scrot
'si gnome-screenshot
ile değiştirebilir, ancak çok fazla iş gerektirebilir. Çıktıyla ilgili olarak, bir metin dosyasını okuyabilecek herhangi bir şey kullanabilirsiniz (Metin Düzenleyicisi ile açık, tanınmış metni bir bildirim olarak gösterme, vb.).
Komut dosyasının GUI sürümü
İşte, OCR komut dosyasının dil seçimi diyaloğu dahil basit bir grafik versiyonu:
#!/bin/bash
# DEPENDENCIES: tesseract-ocr imagemagick scrot yad
# AUTHOR: Glutanimate 2013 (http://askubuntu.com/users/81372/)
# NAME: ScreenOCR
# LICENSE: GNU GPLv3
#
# BASED ON: OCR script by Salem (http://askubuntu.com/a/280713/81372)
TITLE=ScreenOCR # set yad variables
ICON=gnome-screenshot
# - tesseract won't work if LC_ALL is unset so we set it here
# - you might want to delete or modify this line if you
# have a different locale:
export LC_ALL=en_US.UTF-8
# language selection dialog
LANG=$(yad \
--width 300 --entry --title "$TITLE" \
--image=$ICON \
--window-icon=$ICON \
--button="ok:0" --button="cancel:1" \
--text "Select language:" \
--entry-text \
"eng" "ita" "deu")
# - You can modify the list of available languages by editing the line above
# - Make sure to use the same ISO codes tesseract does (man tesseract for details)
# - Languages will of course only work if you have installed their respective
# language packs (https://code.google.com/p/tesseract-ocr/downloads/list)
RET=$? # check return status
if [ "$RET" = 252 ] || [ "$RET" = 1 ] # WM-Close or "cancel"
then
exit
fi
echo "Language set to $LANG"
SCR_IMG='mktemp' # create tempfile
trap "rm $SCR_IMG*" EXIT # make sure tempfiles get deleted afterwards
scrot -s $SCR_IMG.png -q 100 #take screenshot of area
mogrify -modulate 100,0 -resize 400% $SCR_IMG.png # postprocess to prepare for OCR
tesseract -l $LANG $SCR_IMG.png $SCR_IMG # OCR in given language
cat $SCR_IMG | xsel -bi # pass to clipboard
exit
Yukarıda listelenen bağımlılıkların yanı sıra Zenity fork YAD'yi yüklemeniz gerekir. komut dosyasını çalıştırmak için webupd8 PPA 'dan.