OCR using Tesseract

Dolphin Service Menus

Source i (link to git-repo or to original if based on someone elses unmodified work):

Add the source-code for this project on opencode.net

2
Become a Fan
6.1

Description:
This Dolphin/Konqueror service menu will give you a possibility to OCR images conveniently in your file manager window.

This is a very simple program. It OCR's a document and puts it into a file that has the same name as the OCRed image file but with a txt extension.

For the menu to be visible and have basic functionality (OCR tif files) you have to have tesseract-ocr installed and in your path, as well as the desired language packages. (The menu is tested against tesseract-ocr v. 2.03 and 2.04).

To be able to OCR png and jpeg images you have to have imagemagick installed. To be able to OCR pdf file you have to have ghostscript installed.

TRANSLATION: Find the translatable strings at: http://pastebin.com/QV7vV7jn, do the translation and forward those to me via a personal message or email.

INSTALLATION: Install through the Dolphin settings menu. If it does not work, LET ME KNOW and see the readme.txt file for alternative installation methods.

KNOWN PROBLEMS: none at present.

TROUBLESHOOTING: If you experience problems, and you get no output:

1. Ensure that you do have tesseract installed, as well as the appropriate language packs that you use. Also, check that you have imagemagick, ghostscript installed if you want it to work with images other than plain tif. In Debian/ubuntu, commands "dpkg -l | grep tesseract" "dpkg -l | grep imagemagick" "dpkg -l | grep ghostscript" will tell you what you have installed.

2. Check if the problem you experience is in the tesseract engine itself. To do this: a) download this image (http://ftp.akl.lt/users/dgvirtual/ocr_using_tesseract/testimage.tif) and run tesseract against it in console first using english ("tesseract testimage.tif testoutput") and then the language you have problems with (say – Spanish: "tesseract testimage.tif testoutput -l spa"). If you get the file testoutput.txt with text in both cases (it should not be nice), then the problem is not in tesseract or your tesseract installation. Otherwise, consult tesseract ocr website and forums for solution.

2. To troubleshoot the problems related to the service menu, test it against the image you downloaded in the previous step. If it works, test against other images in http://ftp.akl.lt/users/dgvirtual/ocr_using_tesseract/ – if it does not, there must be a problem with imagemagick (png, gif, jpg) or ghostscript (pdf) installations.

3. To figure out what problems could there be in the script and to get help from me, please run the shell script from the service menu archive ocr_using_tesseract.sh against the image with a trouble like this "ocr_using_tesseract.sh en image.png" (note the "en" and not "eng" here) and send the image, the output txt file and the output produced by command to me (my email is in readme.txt file).
Last changelog:

v. 0.3 – 2010-09-30
- The service menu is now fully localizable
- Limitation for uppercase extensions removed


v. 0.2.1 – 2010-09-27
- removed a bug that prevented the service menu to be displayed for PDF
files
- removed the accidental likewise named file overwrite problem
- got the readme.txt file back
- added German translation to the service menu thanks to Rettich

v. 0.2 – 2010-09-24
- attempted to make it knewstuff3 compatible – must be installible through the Dolphin services.
- siplified operation – a dialog asks to choose language, while there is only one service menu entry now.
- fixed progress bar error.
- it seems that the problem with directory names with spaces is gone.

v. 0.1 – 2010-03-10
- Initial creation of the service menu.


Ratings & Comments

12 Comments

conar

Forget to mention: dpkg -l | grep tess ii tesseract-ocr 2.04-2+b1 Command line OCR tool ii tesseract-ocr-eng 2.00-2 tesseract-ocr language files for English text ii tesseract-ocr-spa 2.00-2 tesseract-ocr language files for Spanish text

dgvirtual

Thanks for reporting this. I really do not know if I had done correctly the installation part – I cannot install ANY service menus on my Kubuntu 10.04 with KDE 4.5.1, so cannot troubleshoot that. All I know is that it installs once you unpack it and run ./install-it.sh, and uninstalls running ./uninstall.sh, so it kind of should work.. Re the other problem – could you try simply running "tesseract yourfile.tif youroutput -l spa" (if it is not a tif, convert it to tif somehow) and see if it works. Maybe the problem is in tesseract? if it works on simple tif with spanish, does my service menu work on simple tif? If not, could you please email me the modifications you made in the script and your test image? My email is in readme.txt in the package. By the way, what is your locale? Does it work if you change your locale to english?

conar

Problem solve with Tesseract 3.0.

conar

I have found following issues: 1.- In Debian amd64 (Squeeze) can not be installed via dolphin 2.- INstalling manually only works english lang. Adding spa lang shows next errors: Tesseract Open Source OCR Engine tesseract: unicharset.cpp:76: const UNICHAR_ID UNICHARSET::unichar_to_id(const char*, int) const: Assertion `ids.contains(unichar_repr, length)' failed. /usr/bin/ocr_using_tesseract.sh: line 90: 14225 Aborted tesseract "$INPUTFILE.$time.tif" "$OUTPUTFILE" -l "$LANGUAGE"

stalin2000

with 123@kanotixkde4:/media/sdb1/Dokumente/Papiere$ ocr_using_tesseract.sh deu diplomanmeldung.jpg it worked in the console, but it doesn't work if I do it via right-click menu

dgvirtual

Right, there is no language "ger" in tesseract, but tesseract is so much underdeveloped that it does not tell you that. And for me it works both in console and through the menu... So I am not sure what the problem is. Maybe you made a mistake when modifying the *.desktop file – try it using english language (the one, I assume, you did not modify) – if it works, then there is a mistake in the german part :) Could you please review it, and if you do not find any fault – post it here? By the way, the output you get on that file is not the best since the image is not sharp enough for tesseract. I opened it with gimp and applied threshold – i immediately got a sharper picture and consequently – better results. You can also modify the image using this command: convert diplomanmeldung.jpg -threshold 45% -monochrome diplomanmeldung45.jpg The threshold percentages will vary depending on the image... Here are results with your original file: http://pastebin.ca/1942257 Here is the modified image: http://imagebin.ca/view/srt5cD.html And the results with the modified image: http://pastebin.ca/1942262

stalin2000

Output is: 123@kanotixkde4:/media/sdb1/Dokumente/Papiere$ ocr_using_tesseract.sh ger diplomanmeldung.jpg Unable to load unicharset file /usr/share/tesseract-ocr/tessdata/ger.unicharset File is: http://www.christopherstark.de/extern/diplomanmeldung.jpg

stalin2000

it doesn't work with debian squeeze/kanotix... Tresserct is installed.... the file doesn't have spaces... The tiff file is produced but there is no txt file in the end

dgvirtual

ok, lets troubleshoot... First, check if imagemagick is installed – it has a tool "convert" that is used in the script. it can be done in Debian thus: "dpkg -l | grep imagemagick" – if it outputs the name and version of imagemagick, then this is more than a missing dependency problem... Could you then send me an image that does not work? And also: 1. list of instaled tesseract packages (in Debian can be obtained running: "dpkg -l | grep tesseract") 2. output of running ocr_using_tesseract.sh from the console on the image you send me? The command should be run this way: "ocr_using_tesseract.sh eng your_image.png" my email is in every file of the service menu...

molecule-eye

Is it possible to add the text as a "layer" to the pdf file it was extracted from, just liked Acrobat's OCR feature does? I imagine not, but it's worth asking.

dgvirtual

In general it is possible in Linux – I heard you can use a gtk+ program [url=http://gscan2pdf.sourceforge.net]gscan2pdf[/url]. It has Tesseract-OCR as a possible dependency. However, I am not sure how it is done on command line, therefore – not sure this function can be integrated into these service menus.

dgvirtual

Here is how it is done on command line: using hocr2pdf utility from exactimage package. However, you have to use cuneiform ocr to get the text file. You can also google for two utilities that automate this process (again, using Cuneiform): pdfsandwitch and pdfocr. Unfortunately, not all is well with the international characters: the embedded lithuanian is effectively stripped of all specific national characters... But English pretty much works!

Pling
0 Affiliates
Details
license
version 0.3
updated
added
downloads 24h 3
mediaviews 24h 0
pageviews 24h 4

Other Dolphin Service Menus:

burnWithGrowisofs
chunkylover
last update date: 20 years ago

Score 5.0

Firefox-bookmarks service menu
storyteller
last update date: 20 years ago

Score 5.0

Text Convert Service Menu
smp-penguin
last update date: 21 years ago

Score 5.0

Pdflatex servicemenu
bobuse
last update date: 20 years ago

Score 5.0

Send through Bluetooth
dmnet
last update date: 21 years ago

Score 5.0

Add to Bloglines
spookster
last update date: 20 years ago

Score 5.0



System Tags