info:ocr

Ceci est une ancienne révision du document !


Reconnaissance optique de caractères

utiliser tesseract (cf infra)

PDF > txt directement avec un script bash linux

requiert tesseract:

sudo apt-get install tesseract
#!/usr/bin/bash
# pdf_ocr2txt
ls *.pdf | while read i
do
	echo "converting pdf file: " $i " to tif file " $i.tif
	convert -density 400 -depth 8 $i $i.tif
	echo "-----"
	echo "Generating txt file " $i.txt
	tesseract $i.tif $i.txt -l fra
done

http://doc.ubuntu-fr.org/tesseract-ocr

 convert -density 300 file.pdf -depth 8 file.tiff  
 tesseract file.tiff file.txt -l fra
 
#!/bin/sh
echo "convertit un document pdf et réalise une reconnaissance optique de caractères"
echo "entrer le nom du fichier"
ls *.pdf
read fichier
echo "combien de pages?"
read npages
PAGES=$npages # set to the number of pages in the PDF
SOURCE=$fichier # set to the file name of the PDF
OUTPUT=$fichier.txt # set to the final output file
RESOLUTION=600 # set to the resolution the scanner used (the higher, the better)

#xpdf-pdfinfo pamphlet-low.pdf | grep Pages: | awk '{print $2}' | tail -n 1

#touch $OUTPUT
for i in `seq 1 $PAGES`; do
    convert -density $RESOLUTION -depth 8 $SOURCE\[$(($i - 1 ))\] page$i.png
##    tesseract page$i.tif >> $OUTPUT
    tesseract page$i.png $OUTPUT$i -l fra
done

http://www.tristancollins.me/computing/ocr-using-tesseract-on-multipage-pdfs/

http://code.google.com/p/tesseract-ocr/

marche nickel!

par contre pas en russe, je suis à la recherche… y'a visiblement du monde qui y bosse:

http://groups.google.com/group/tesseract-ocr-russian/

http://groups.google.com/group/tesseract-ocr-russian/files

voir aussi:

http://code.google.com/p/owlboxer/

, ocrad et gocr tentent de rattraper le retard linuxien en matière d'OCR

apt-get install ocrad gocr

Faut avouer que c'est moins performant que les produits windaube…

Un petit script pratique pour ocrad (que je préfère nettement à gocr, notamment plus rapide)

ocr.sh

#! /bin/bash
# ocr.sh
# Usage:
# ocr.sh
# script bash pour convertir des fichiers images en *.pbm et les traiter ensuite automatiquement avec le 
# logiciel de reconnaissance optique de caractères (OCR) ocrad pour en extraire un fichier texte
# Required: convert, ocrad
# FR, fradeff@akademia.ch, www.unige.ch
# History  2008/10/29, created FR
############
# se placer dans le répertoire dans lequel on a stocké les pages scannées ou photographièes, ici des fichiers JPG
mkdir pbm #cree un rep de travail
find . -name "*.JPG" | while read i #trouve les fichiers JPG
do
	convert $i pbm/$i.pbm #les convertit dans un format accepte par ocrad via convert
done
echo "Tous les fichiers images ont été convertis"

cd pbm #va dans le rep de travail
find . | while read i
do
	ocrad $i >> result.txt #fait l'OCR
done

echo "Voici le résultat:"
more result.txt
  • info/ocr.1531899970.txt.gz
  • Dernière modification : 2018/07/18 09:46
  • de radeff