oHTML (ang. Optic HyperText Markup Language) - Optical character recognition and HTML layout analysis library
Project description
ohtml
ohtml -> oHTML (ang. Optic HyperText Markup Language, optyczny hipertekstowy język znaczników) – język znaczników stosowany do tworzenia dokumentów hipertekstowych. na bazie optycznej detekcji obrazu
Instrukcje instalacji:
-
Utwórz środowisko wirtualne: python -m venv pdf_analyzer_env source pdf_analyzer_env/bin/activate Linux/Mac pdf_analyzer_env\Scripts\activate Windows
-
Zainstaluj zależności: pip install -r requirements.txt
-
Zainstaluj Tesseract OCR:
- Ubuntu/Debian: sudo apt-get install tesseract-ocr tesseract-ocr-pol tesseract-ocr-deu
- Windows: Pobierz z https://github.com/UB-Mannheim/tesseract/wiki
- macOS: brew install tesseract tesseract-lang
-
Opcjonalnie - modele spaCy: python -m spacy download pl_core_news_sm python -m spacy download en_core_web_sm python -m spacy download de_core_news_sm
📋 Przewodnik Instalacji i Konfiguracji PDF Analyzer
🎯 Przegląd Systemu
PDF Analyzer to modularny system do inteligentnej analizy dokumentów PDF z automatyczną segmentacją na bloki tekstu, OCR i generowaniem struktury HTML z metadanymi JSON. System wykorzystuje OpenCV do analizy układu, Tesseract/EasyOCR do rozpoznawania tekstu i generuje responsywne HTML z osadzonymi metadanymi.
🛠️ Wymagania Systemowe
Obsługiwane Systemy:
- Linux (Ubuntu 18.04+, Debian 10+, CentOS 7+)
- Windows (10/11)
- macOS (10.14+)
Wymagania Sprzętowe:
- RAM: minimum 4GB, zalecane 8GB+
- CPU: 2+ rdzenie
- Miejsce na dysku: 2GB dla instalacji + miejsce na dokumenty
- GPU: opcjonalnie dla przyspieszenia OCR
📦 Instalacja Krok po Kroku
Krok 1: Przygotowanie Środowiska
# Utwórz katalog projektu
mkdir pdf_analyzer_project
cd pdf_analyzer_project
# Utwórz środowisko wirtualne Python
python3 -m venv pdf_analyzer_env
# Aktywuj środowisko wirtualne
# Linux/macOS:
source pdf_analyzer_env/bin/activate
# Windows:
pdf_analyzer_env\Scripts\activate
Krok 2: Instalacja Tesseract OCR
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install tesseract-ocr tesseract-ocr-pol tesseract-ocr-deu tesseract-ocr-eng
sudo apt-get install libtesseract-dev libleptonica-dev
Windows:
- Pobierz installer z: https://github.com/UB-Mannheim/tesseract/wiki
- Zainstaluj z obsługą języków polskiego, niemieckiego i angielskiego
- Dodaj ścieżkę Tesseract do PATH (np.
C:\Program Files\Tesseract-OCR)
macOS:
brew install tesseract tesseract-lang
Krok 3: Instalacja Poppler (dla pdf2image)
Ubuntu/Debian:
sudo apt-get install poppler-utils
Windows:
- Pobierz Poppler z: https://github.com/oschwartz10612/poppler-windows/releases
- Rozpakuj i dodaj
bindo PATH
macOS:
brew install poppler
Krok 4: Instalacja Bibliotek Python
# Utwórz requirements.txt (skopiuj z artefaktu)
pip install --upgrade pip
pip install -r requirements.txt
Krok 5: Sprawdzenie Instalacji
# test_installation.py
import cv2
import pytesseract
from pdf2image import convert_from_path
import numpy as np
from PIL import Image
import langdetect
print("✅ OpenCV:", cv2.__version__)
print("✅ Tesseract:", pytesseract.get_tesseract_version())
print("✅ PDF2Image: OK")
print("✅ Instalacja kompletna!")
# Test OCR
test_img = Image.new('RGB', (200, 50), color='white')
from PIL import ImageDraw, ImageFont
draw = ImageDraw.Draw(test_img)
draw.text((10, 10), "Test OCR", fill='black')
text = pytesseract.image_to_string(test_img, lang='eng')
print("✅ OCR Test:", text.strip())
🚀 Pierwsze Uruchomienie
Struktura Katalogów:
pdf_analyzer_project/
├── pdf_analyzer_env/ # Środowisko wirtualne
├── src/
│ ├── pdf_analyzer.py # Główny kod systemu
│ ├── usage_examples.py # Przykłady użycia
│ └── requirements.txt # Zależności
├── input/ # Katalog na PDF do analizy
├── output/ # Katalog na wyniki
└── tests/ # Pliki testowe
Test Podstawowy:
# Uruchom analizę
python src/pdf_analyzer.py invoice/241002.pdf
# Sprawdź wyniki w katalogu output/
ls -la output/
⚙️ Konfiguracja i Dostrajanie
Parametry OCR (w pdf_analyzer.py):
# Dla lepszej jakości OCR
custom_config = r'--oem 3 --psm 6 -l pol+eng+deu -c tessedit_char_whitelist=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzĄĆĘŁŃÓŚŹŻąćęłńóśźż'
# Dla dokumentów z małym tekstem
custom_config = r'--oem 3 --psm 6 -l pol+eng+deu -c tessedit_char_whitelist=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzĄĆĘŁŃÓŚŹŻ'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vhtml-0.1.3.tar.gz.
File metadata
- Download URL: vhtml-0.1.3.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.3 Linux/6.14.0-15-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d1de6194d3e1e16d119762d21b3b6cfb4aac835bbe512826ec2dcd8bc1fe7b6
|
|
| MD5 |
403967e0ede41e1a3eeaa53425def2db
|
|
| BLAKE2b-256 |
cd09ba7a466b1ee8408bf7271dec1db0362cbd91ec09be3767719f9a50b19672
|
File details
Details for the file vhtml-0.1.3-py3-none-any.whl.
File metadata
- Download URL: vhtml-0.1.3-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.3 Linux/6.14.0-15-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4384fa08822ca2094dd50c616b5ec83e71d381654eee3115935e9f6dbdd81416
|
|
| MD5 |
cf7e352aa7d4a2dbd73a1a0b41486537
|
|
| BLAKE2b-256 |
df4d8547642c9b23876bbc24e5ab3aad888ea6059a411e974c05c39be00d2cbc
|