


Xsel -bi < "$SCR_IMG".txt # pass to clipboardĪside from the dependencies listed above you will need to install the Zenity fork YAD from the webupd8 PPA to make the script work.ĭon't know if any one need my solution.

Tesseract -l "$LANG" "$SCR_IMG".png "$SCR_IMG" # OCR in given language Mogrify -modulate 100,0 -resize 400% "$SCR_IMG".png # postprocess to prepare for OCR Scrot -s "$SCR_IMG".png -q 100 #take screenshot of area Trap "rm $SCR_IMG*" EXIT # make sure tempfiles get deleted afterwards # - Languages will of course only work if you have installed their respective # - Make sure to use the same ISO codes tesseract does (man tesseract for details) # - You can modify the list of available languages by editing the line above # - you might want to delete or modify this line if you # - tesseract won't work if LC_ALL is unset so we set it here # DEPENDENCIES: tesseract-ocr imagemagick scrot yad Here's a simple graphical version of the OCR script including a language selection dialog: #!/bin/bash Regarding the output you can use anything that can read a text file (open with Text Editor, show the recognized text as a notification, etc). You may be able to replace scrot with gnome-screenshot, but it may take a lot of work. NOTE: scrot, xsel, imagemagick and tesseract-ocr are not installed by default but are available from the the default repositories. The clipboard version additionally utilizes xsel to pipe the output into the clipboard. It uses scrot to take the screen, tesseract to recognize the text and cat to display the result. # increase image quality with option -q from default 75 to 100 # quick language menu, add more if you need other languages. # Dependencies: tesseract-ocr imagemagick scrot xsel Tesseract $SCR_IMG.png $SCR_IMG &> /dev/null Mogrify -modulate 100,0 -resize 400% $SCR_IMG.png # Typo "$SCR_IMG.png000" does not continue with same name. # increase quality with option -q from default 75 to 100 # Quick language menu, add more if you need other languages. Select tesseract_lang in eng rus equ do break done # Dependencies: tesseract-ocr imagemagick scrot Take as an example this script (in my system I saved it as /usr/local/bin/screen_ts): #!/bin/bash Maybe there is already some tool that does that, but you can also create a simple script with some screenshot tool and tesseract, as you are trying to use.
