Neural Math OCR

Handwritten notation to LaTeX pipeline

PythonOpenCVPyTorchXeLaTeX

The Problem

Converting handwritten university lecture notes into structured, professional LaTeX PDFs is manually exhausting, especially for complex mathematical notation.

Architecture

Vision Core

OpenCV

Binarization & deskewing

Inference

pix2tex (Transformer)

Formula prediction

Engine

XeLaTeX

PDF compilation

Localization

Polyglossia

Multi-language support

Implementation

Developed a Python-based preprocessing engine that handles noise reduction and contrast enhancement before feeding segments to a pre-trained Vision Transformer. The output is dynamically injected into Jinja2 LaTeX templates and compiled via XeLaTeX to ensure perfect mathematical typesetting.

Transcribe Time

8s

per page

Accuracy

96.4%

verified

Format

PDF/TEX

dual output

Key Learnings

"Preprocessing is 80% of OCR success. Simple deskewing algorithms improved model accuracy by over 30% compared to raw photo imports."