Skip to content

Instantly share code, notes, and snippets.

@zuphilip
Last active September 8, 2021 00:29
Show Gist options
  • Save zuphilip/7f6026e863b03e94121d073b0774e9b6 to your computer and use it in GitHub Desktop.
Save zuphilip/7f6026e863b03e94121d073b0774e9b6 to your computer and use it in GitHub Desktop.
Tesseract IPython Notebook
tesseract-ocr
tesseract-ocr-deu
tesseract-ocr-script-latn
tesseract-ocr-script-frak
libtesseract-dev
ocrmypdf
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" from PIL import Image\n",
"except ImportError:\n",
" import Image\n",
"\n",
"import pytesseract"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"LooseVersion ('4.0.0-beta.1')"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pytesseract.get_tesseract_version()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(pytesseract.image_to_string(Image.open('test.png')))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Usage:\r\n",
" tesseract --help | --help-extra | --version\r\n",
" tesseract --list-langs\r\n",
" tesseract imagename outputbase [options...] [configfile...]\r\n",
"\r\n",
"OCR options:\r\n",
" -l LANG[+LANG] Specify language(s) used for OCR.\r\n",
"NOTE: These options must occur before any configfile.\r\n",
"\r\n",
"Single options:\r\n",
" --help Show this help message.\r\n",
" --help-extra Show extra help for advanced users.\r\n",
" --version Show version information.\r\n",
" --list-langs List available languages for tesseract engine.\r\n"
]
}
],
"source": [
"!tesseract -h"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"List of available languages (2):\r\n",
"osd\r\n",
"eng\r\n"
]
}
],
"source": [
"!tesseract --list-langs"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment