Package: aiopytesseract
aiopytesseractA Pythonasynciowrapper forTesseract-OCR.InstallationInstall and update using pip:pipinstallaiopytesseractUsageList all available languages by Tesseract installationimportaiopytesseractawaitaiopytesseract.languages()awaitaiopytesseract.get_languages()Tesseract versionimportaiopytesseractawaitaiopytesseract.tesseract_version()awaitaiopytesseract.get_tesseract_version()Tesseract parametersimportaiopytesseractawaitaiopytesseract.tesseract_parameters()Confidence only infoimportaiopytesseractawaitaiopytesseract.confidence("tests/samples/file-sample_150kB.png")Deskew infoimportaiopytesseractawaitaiopytesseract.deskew("tests/samples/file-sample_150kB.png")Extract text from an image: locally or bytesfrompathlibimportPathimportaiopytesseractawaitaiopytesseract.image_to_string("tests/samples/file-sample_150kB.png")awaitaiopytesseract.image_to_string(Path("tests/samples/file-sample_150kB.png").read_bytes(),dpi=220,lang='eng+por')Box estimatesfrompathlibimportPathimportaiopytesseractawaitaiopytesseract.image_to_boxes("tests/samples/file-sample_150kB.png")awaitaiopytesseract.image_to_boxes(Path("tests/samples/file-sample_150kB.png")Boxes, confidence and page numbersfrompathlibimportPathimportaiopytesseractawaitaiopytesseract.image_to_data("tests/samples/file-sample_150kB.png")awaitaiopytesseract.image_to_data(Path("tests/samples/file-sample_150kB.png")Information about orientation and script detectionfrompathlibimportPathimportaiopytesseractawaitaiopytesseract.image_to_osd("tests/samples/file-sample_150kB.png")awaitaiopytesseract.image_to_osd(Path("tests/samples/file-sample_150kB.png")Generate a searchable PDFfrompathlibimportPathimportaiopytesseractawaitaiopytesseract.image_to_pdf("tests/samples/file-sample_150kB.png")awaitaiopytesseract.image_to_pdf(Path("tests/samples/file-sample_150kB.png")Generate HOCR outputfrompathlibimportPathimportaiopytesseractawaitaiopytesseract.image_to_hocr("tests/samples/file-sample_150kB.png")awaitaiopytesseract.image_to_hocr(Path("tests/samples/file-sample_150kB.png")Multi ouputfrompathlibimportPathimportaiopytesseractasyncwithaiopytesseract.run(Path('tests/samples/file-sample_150kB.png').read_bytes(),'output','alto tsv txt')asresp:# will generate (output.xml, output.tsv and output.txt)print(resp)alto_file,tsv_file,txt_file=respConfig variablesfrompathlibimportPathimportaiopytesseractasyncwithaiopytesseract.run(Path('tests/samples/text-with-chars-and-numbers.png').read_bytes(),'output','alto tsv txt'config=[("tessedit_char_whitelist","0123456789")])asresp:# will generate (output.xml, output.tsv and output.txt)print(resp)alto_file,tsv_file,txt_file=respfrompathlibimportPathimportaiopytesseractawaitaiopytesseract.image_to_string("tests/samples/text-with-chars-and-numbers.png",config=[("tessedit_char_whitelist","0123456789")])awaitaiopytesseract.image_to_string(Path("tests/samples/text-with-chars-and-numbers.png").read_bytes(),dpi=220,lang='eng+por',config=[("tessedit_char_whitelist","abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")])For more details on Tesseract best practices and the aiopytesseract, see the folder:docs.ExamplesIf you want to testaiopytesseracteasily, can you use some options like:docker/docker-composestreamlitDocker / docker-composeAfter clone this repo run the command below:docker-composeup-dstreamlit appFor this option it's necessary first installaiopytesseractandstreamlit, after execute:# remote option:streamlitrunhttps://github.com/amenezes/aiopytesseract/blob/master/examples/streamlit/app.py# local option:streamlitrunexamples/streamlit/app.pynote: The streamlit example needpython >= 3.10LinksLicense:Apache LicenseCode:https://github.com/amenezes/aiopytesseractIssue tracker:https://github.com/amenezes/aiopytesseract/issuesDocs:https://github.com/amenezes/aiopytesseract