diff --git a/README.es-ES.md b/README.es-ES.md new file mode 100644 index 0000000..f14e665 --- /dev/null +++ b/README.es-ES.md @@ -0,0 +1,224 @@ + + +[![ci](https://github.com/amenezes/aiopytesseract/actions/workflows/ci.yml/badge.svg)](https://github.com/amenezes/aiopytesseract/actions/workflows/ci.yml) +[![codecov](https://codecov.io/gh/amenezes/aiopytesseract/branch/master/graph/badge.svg)](https://codecov.io/gh/amenezes/aiopytesseract) +[![PyPI version](https://badge.fury.io/py/aiopytesseract.svg)](https://badge.fury.io/py/aiopytesseract) +![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aiopytesseract) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) + +# aiopytesseract + +Un envoltorio para [Tesseract-OCR](https://tesseract-ocr.github.io/tessdoc/) en Python basado en [asyncio](https://docs.python.org/3/library/asyncio.html). + +## Instalación + +Instale y actualice usando pip: + +````bash +pip install aiopytesseract +```` + +## Uso + +### Listar todos los idiomas disponibles según la instalación de Tesseract + +``` python +import aiopytesseract + +await aiopytesseract.languages() +await aiopytesseract.get_languages() +``` + +### Versión de Tesseract + +``` python +import aiopytesseract + +await aiopytesseract.tesseract_version() +await aiopytesseract.get_tesseract_version() +``` + +### Parámetros de Tesseract + +``` python +import aiopytesseract + +await aiopytesseract.tesseract_parameters() +``` + +### Solo información de confianza + +``` python +import aiopytesseract + +await aiopytesseract.confidence("tests/samples/file-sample_150kB.png") +``` + +### Información de corrección de inclinación (deskew) + +``` python +import aiopytesseract + +await aiopytesseract.deskew("tests/samples/file-sample_150kB.png") +``` + +### Extraer texto de una imagen: local o bytes + +``` python +from pathlib import Path + +import aiopytesseract + +await aiopytesseract.image_to_string("tests/samples/file-sample_150kB.png") +await aiopytesseract.image_to_string( + Path("tests/samples/file-sample_150kB.png").read_bytes(), dpi=220, lang='eng+por' +) +``` + +### Estimaciones de cajas + +``` python +from pathlib import Path + +import aiopytesseract + +await aiopytesseract.image_to_boxes("tests/samples/file-sample_150kB.png") +await aiopytesseract.image_to_boxes(Path("tests/samples/file-sample_150kB.png") +``` + +### Cajas, confianza y números de página + +``` python +from pathlib import Path + +import aiopytesseract + +await aiopytesseract.image_to_data("tests/samples/file-sample_150kB.png") +await aiopytesseract.image_to_data(Path("tests/samples/file-sample_150kB.png") +``` + +### Información sobre detección de orientación y escritura + +``` python +from pathlib import Path + +import aiopytesseract + +await aiopytesseract.image_to_osd("tests/samples/file-sample_150kB.png") +await aiopytesseract.image_to_osd(Path("tests/samples/file-sample_150kB.png") +``` + +### Generar un PDF buscable + +``` python +from pathlib import Path + +import aiopytesseract + +await aiopytesseract.image_to_pdf("tests/samples/file-sample_150kB.png") +await aiopytesseract.image_to_pdf(Path("tests/samples/file-sample_150kB.png") +``` + +### Generar salida HOCR + +``` python +from pathlib import Path + +import aiopytesseract + +await aiopytesseract.image_to_hocr("tests/samples/file-sample_150kB.png") +await aiopytesseract.image_to_hocr(Path("tests/samples/file-sample_150kB.png") +``` + +### Salida múltiple + +``` python +from pathlib import Path + +import aiopytesseract + +async with aiopytesseract.run( + Path('tests/samples/file-sample_150kB.png').read_bytes(), + 'output', + 'alto tsv txt' +) as resp: + # will generate (output.xml, output.tsv and output.txt) + print(resp) + alto_file, tsv_file, txt_file = resp +``` + +### Variables de configuración + +``` python +from pathlib import Path + +import aiopytesseract + +async with aiopytesseract.run( + Path('tests/samples/text-with-chars-and-numbers.png').read_bytes(), + 'output', + 'alto tsv txt' + config=[("tessedit_char_whitelist", "0123456789")] +) as resp: + # will generate (output.xml, output.tsv and output.txt) + print(resp) + alto_file, tsv_file, txt_file = resp +``` + +``` python +from pathlib import Path + +import aiopytesseract + +await aiopytesseract.image_to_string( + "tests/samples/text-with-chars-and-numbers.png", + config=[("tessedit_char_whitelist", "0123456789")] +) + +await aiopytesseract.image_to_string( + Path("tests/samples/text-with-chars-and-numbers.png").read_bytes(), + dpi=220, + lang='eng+por', + config=[("tessedit_char_whitelist", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")] +) +``` + +> Para más detalles sobre las mejores prácticas de Tesseract y de aiopytesseract, consulte la carpeta: `docs`. + +## Ejemplos + +Si desea probar **aiopytesseract** fácilmente, puede usar algunas opciones como: + +- docker/docker-compose +- [streamlit](https://streamlit.io) + +### Docker / docker-compose + +Después de clonar este repositorio, ejecute el siguiente comando: + +```bash +docker-compose up -d +``` + +### Aplicación streamlit + +Para esta opción, es necesario primero instalar `aiopytesseract` y `streamlit`, y luego ejecutar: + +``` py +# remote option: +streamlit run https://github.com/amenezes/aiopytesseract/blob/master/examples/streamlit/app.py +``` + +``` py +# local option: +streamlit run examples/streamlit/app.py +``` + +> nota: El ejemplo de streamlit requiere **python >= 3.13** + +## Enlaces + +- Licencia: [Apache License](https://choosealicense.com/licenses/apache-2.0/) +- Código: [https://github.com/amenezes/aiopytesseract](https://github.com/amenezes/aiopytesseract) +- Rastreador de incidencias: [https://github.com/amenezes/aiopytesseract/issues](https://github.com/amenezes/aiopytesseract/issues) +- Documentación: [https://github.com/amenezes/aiopytesseract](https://github.com/amenezes/aiopytesseract)