Skip to main content

vhtml (ang. Visual HyperText Markup Language) - Optical character recognition and HTML layout analysis library

Project description

vhtml

vhtml -> vhtml (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:

  1. Utwórz środowisko wirtualne: python -m venv pdf_analyzer_env source pdf_analyzer_env/bin/activate Linux/Mac pdf_analyzer_env\Scripts\activate Windows

  2. Zainstaluj zależności: pip install -r requirements.txt

  3. Zainstaluj Tesseract OCR:

  4. 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:

  1. Pobierz installer z: https://github.com/UB-Mannheim/tesseract/wiki
  2. Zainstaluj z obsługą języków polskiego, niemieckiego i angielskiego
  3. 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:

  1. Pobierz Poppler z: https://github.com/oschwartz10612/poppler-windows/releases
  2. Rozpakuj i dodaj bin do 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:

241002.pdf

# 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vhtml-0.1.5.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vhtml-0.1.5-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file vhtml-0.1.5.tar.gz.

File metadata

  • Download URL: vhtml-0.1.5.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

Hashes for vhtml-0.1.5.tar.gz
Algorithm Hash digest
SHA256 1230242f59b84efd2af6bb0028a78088f12adb7b58b9a21c3ac444941bc8717b
MD5 9a0dda899f7633ed1d1a700a2ec1f2ad
BLAKE2b-256 0361ae959cd855d9fde6a0c9d43bfd993e8ac8a4f02fc8a7441746046cb286f4

See more details on using hashes here.

File details

Details for the file vhtml-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: vhtml-0.1.5-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

Hashes for vhtml-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 66861b4fcd3b32d12f8930a00bb71af3f4d14ed82d230d129a5f8dfb36d20048
MD5 d97d7c75559871e916e246ced0cf1214
BLAKE2b-256 12010926266e23fb64432f74d7a29e216402dccf7b2286f6e912398684c9e2af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page