Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| info:ocr [2016/09/19 19:32] – [tesseract] radeff | info:ocr [2024/05/16 02:51] (Version actuelle) – radeff | ||
|---|---|---|---|
| Ligne 2: | Ligne 2: | ||
| utiliser tesseract (cf infra) | utiliser tesseract (cf infra) | ||
| ====== PDF > txt directement avec un script bash linux ====== | ====== PDF > txt directement avec un script bash linux ====== | ||
| + | requiert tesseract: | ||
| - | un grand merci à Frans de Jonge pour son excellent script: http:// | + | sudo apt-get install tesseract-ocr tesseract-ocr-fra |
| - | + | ||
| - | < | + | < |
| - | # | + | |
| - | # | + | |
| - | # Simplified implementation of http:// | + | |
| - | # mod Frans de Jong http:// | + | |
| - | # mod Fred Radeff, akademia.ch | + | |
| - | # usage: ocrpdftotext PutYourFilename.pdf | + | |
| - | # Might consider doing something with getopts here, see http:// | + | |
| - | DPI=300 | + | |
| - | # | + | |
| - | #adapt to french | + | |
| - | TESS_LANG=fra | + | |
| - | + | ||
| - | FILENAME=${@%.pdf} | + | |
| - | SCRIPT_NAME=`basename " | + | |
| - | TMP_DIR=${SCRIPT_NAME}-tmp | + | |
| - | OUTPUT_FILENAME=${FILENAME}-output@DPI${DPI} | + | |
| - | + | ||
| - | mkdir ${TMP_DIR} | + | |
| - | cp ${@} ${TMP_DIR} | + | |
| - | cd ${TMP_DIR} | + | |
| - | + | ||
| - | convert -density ${DPI} -depth 8 ${@} " | + | |
| - | tesseract " | + | |
| - | + | ||
| - | mv ${OUTPUT_FILENAME}.txt .. | + | |
| - | rm * | + | |
| - | cd .. | + | |
| - | rmdir ${TMP_DIR} | + | |
| - | </ | + | |
| - | + | ||
| - | absolument génial, de l' | + | |
| - | + | ||
| - | 2e version | + | |
| - | < | + | |
| # | # | ||
| # pdf_ocr2txt | # pdf_ocr2txt | ||
| Ligne 79: | Ligne 46: | ||
| tesseract page$i.png $OUTPUT$i -l fra | tesseract page$i.png $OUTPUT$i -l fra | ||
| done</ | done</ | ||
| - | http:// | ||
| + | ==== Liens ==== | ||
| - | http://code.google.com/p/tesseract-ocr/ | + | * https:// |
| + | * http://www.tristancollins.me/computing/ocr-using-tesseract-on-multipage-pdfs/ | ||
| + | * https:// | ||
| marche nickel! | marche nickel! | ||
| + | ===== GUI ===== | ||
| - | par contre | + | Si on veut pas s' |
| + | sudo apt-get install gimagereader | ||
| - | http://groups.google.com/ | + | {{:info: |
| - | http:// | + | si on veut du russe il faudra installer le dictionnaire |
| + | sudo apt install hunspell-ru | ||
| + | et bien sûr le dico français si vous ne l'avez pas déjà | ||
| + | sudo apt install hunspell-fr | ||
| - | voir aussi: | + | ===== Russe ===== |
| - | http://code.google.com/p/owlboxer/ | + | * https://pyimagesearch.com/ |
| + | * https:// | ||
| + | mv rus.traineddata / | ||
| - | ===== Old ===== | + | Ou encore plus simple |
| + | sudo apt-get install tesseract-ocr-rus | ||
| - | , ocrad et gocr tentent | + | ==== exemple |
| - | + | < | |
| - | apt-get install ocrad gocr | + | #!/usr/bin/bash |
| - | + | # ocr-ru: convert (optical character recognition) jpg russian voc to text/csv file | |
| - | Faut avouer que c'est moins performant que les produits windaube... | + | # usage: ocr-ru then translate it and drill it with anki |
| - | + | # copyleft radeff.red - use it at your own risk! | |
| - | Un petit script | + | ladate=$(date +' |
| - | + | echo "ocr which russian image?" | |
| - | + | ls *.jpg | |
| - | ocr.sh | + | read i |
| - | < | + | convert $i $i.png |
| - | #! /bin/bash | + | tesseract $i.png $ladate -l rus |
| - | # ocr.sh | + | rm $i.png |
| - | # Usage: | + | echo "conversion ok, edit " |
| - | # ocr.sh | + | #delete empty lines |
| - | # script bash pour convertir des fichiers images en *.pbm et les traiter ensuite automatiquement avec le | + | sed -i '/ |
| - | # logiciel de reconnaissance optique de caractères | + | #delete line with only spaces |
| - | # Required: convert, ocrad | + | sed -i '/^ *$/d' $ladate.txt |
| - | # FR, fradeff@akademia.ch, www.unige.ch | + | #delete end line with strange char from whatsapp |
| - | # History | + | sed -i '/ |
| - | ############ | + | mv $ladate.txt $ladate.csv |
| - | # se placer dans le répertoire dans lequel on a stocké les pages scannées ou photographièes, | + | geany $ladate".csv"& |
| - | mkdir pbm #cree un rep de travail | + | |
| - | find . -name " | + | |
| - | 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 | + | |
| </ | </ | ||
| - | |||