Notes2TeX is an end-to-end Computer Vision and Multimodal Generative AI system that turns messy handwritten spiral notebook pages, oblique whiteboard photos, and multi-page lecture slide PDFs into publication-grade, compiled LaTeX study guides with live KaTeX math and synthesized vector TikZ diagrams.
Every STEM and CS student experiences the same dilemma: after an intense lecture, students leave with crooked, glare-filled phone snapshots of whiteboards, scribbled notebook formulas, or annotated slide decks.
When reviewing those notes later:
- Unreadable: Distorted by oblique perspective angles, low marker contrast, and harsh fluorescent lighting glare.
- Disconnected: Isolated scribbles and arrows that cannot be searched, copied, or compiled into clean documents.
- Lost in camera rolls: Static raster images that never turn into usable study material.
Notes2TeX solves this. It parses physical visual notes and slide decks into compiled LaTeX study guides with live-rendered KaTeX math, synthesized vector TikZ graphics, and a 1-click Overleaf injector.
Notes2TeX implements an authentic multi-stage Computer Vision and Multimodal Generative AI pipeline designed to eliminate the common pitfalls of raw OCR:
[Handwritten Note / Whiteboard / PDF Slide]
│
▼
┌───────────────────────────────────────────┐
│ STAGE 1: OpenCV Perspective Keystoning │
│ - Canny edge contour quad detection │
│ - 4-point homography warp to flat plane │
└─────────────────────┬─────────────────────┘
│
▼
┌───────────────────────────────────────────┐
│ STAGE 2: Adaptive Glare Suppression │
│ - LAB color space conversion │
│ - CLAHE illumination normalization │
│ - Marker stroke sharpening │
└─────────────────────┬─────────────────────┘
│
▼
┌───────────────────────────────────────────┐
│ STAGE 3: Layout Region Segmentation │
│ - Morphological bounding box clustering │
│ - Periodic text projection profiling │
│ - Classification: Text / Math / Diagram │
└─────────────────────┬─────────────────────┘
│
▼
┌───────────────────────────────────────────┐
│ STAGE 4: Multimodal Synthesis (Gemini 3)│
│ - KaTeX inline & display math parsing │
│ - Generative TikZ vector synthesis │
│ - Local Tesseract OCR fallback pipeline │
└─────────────────────┬─────────────────────┘
│
┌────────────────┴────────────────┐
▼ ▼
[React Studio on :5555] [1-Click Overleaf Extension]
- Bounding-box canvas - Upload photo / PDF & inject
- Live KaTeX preview - Direct CodeMirror DOM paste
- TikZ vector rendering - Zero manual copy-paste
- .tex source editor
-
Perspective Keystoning: Detects document/whiteboard perimeter contours (
cv2.approxPolyDP) and computes a homography matrix (cv2.getPerspectiveTransform) to un-warp angled photos taken from lecture desks into straight orthogonal planes. -
Glare & Lighting Neutralization: Converts images to LAB color space and applies Contrast Limited Adaptive Histogram Equalization (CLAHE) to the
$L$ -channel, suppressing fluorescent reflections while boosting faded marker contrast. - Layout Segmentation: Uses horizontal projection profiling and connected-component dilation to cluster and classify regions into Text, Mathematical Expressions, and Structural Diagrams.
- Math Proof Parsing: Preserves mathematical variables, fractions, integrals, and matrices formatted with standard LaTeX math delimiters.
- Vector TikZ Generation: Synthesizes editable, publication-quality LaTeX TikZ vector graphics from hand-drawn graphs, memory layouts, and flowcharts.
- Resilient Fallback Chain: Automatically cascades across models (
gemini-3-flash-preview,gemini-3.5-flash,gemini-2.0-flash) with local Tesseract OCR fallback for offline operation.
- Interactive Vision Canvas: Visualizes classified bounding boxes with color-coded chips (Text, Math, Diagram). Clicking any box immediately scrolls to and highlights that compiled section in the study guide.
- Live KaTeX Math Engine: Renders mathematical notation side-by-side with raw
.texsource code. - Multi-Page PDF Processing: In-memory PDF rasterization (
pypdfium2) with a dedicated pagination toolbar to navigate and compile multi-page slide decks. - Export Suite: 1-Click download of raw
.texsource files, clipboard copying, and print-ready PDF export.
- Click the Notes2TeX extension icon while working in any Overleaf project.
- Upload any handwritten photo or lecture PDF (or inject the pre-loaded CSE sample).
- The extension communicates with your local vision engine, compiles the note into high-quality LaTeX and TikZ, and programmatically injects it directly into your active Overleaf editor tab at your cursor position—zero copy-pasting required.
notes2tex/
├── backend/
│ ├── main.py # FastAPI REST API, routing & in-memory PDF rasterization
│ ├── cv_engine.py # OpenCV homography, CLAHE glare removal & segmentation
│ ├── ai_engine.py # Gemini 3 Flash multimodal synthesis & TikZ generation
│ └── samples.py # Pre-loaded STEM lecture samples (CSE 320 Virtual Memory)
├── frontend/
│ ├── src/
│ │ ├── App.jsx # Studio state management, tabs & stepper
│ │ ├── components/
│ │ │ ├── Header.jsx # Navigation, upload trigger & export actions
│ │ │ ├── WhiteboardViewer.jsx # Interactive canvas with bounding boxes
│ │ │ ├── StudyGuideViewer.jsx # Live KaTeX math & TikZ vector preview
│ │ │ ├── LatexEditor.jsx # Raw LaTeX code viewer with line metrics
│ │ │ ├── OpenCVInspector.jsx # Computer vision stage metrics inspector
│ │ │ └── ApiKeyModal.jsx # Local browser API key configuration
│ │ └── index.css # Neo-brutalist theme & grid-notebook styling
│ ├── package.json
│ └── vite.config.js
├── extension/
│ ├── manifest.json # Chrome Manifest V3 configuration
│ ├── popup.html # Extension popup interface
│ ├── popup.js # Extension controller & Overleaf tab detector
│ ├── background.js # Background service worker
│ └── content.js # CodeMirror 6 DOM injector for Overleaf tabs
├── start.sh # Concurrent startup script for backend & frontend
├── .gitignore # Strict secret isolation (.env never tracked)
└── README.md
- Python 3.10+ (Python 3.12 recommended)
- Node.js 18+ and npm
git clone https://github.com/sumitkumar91/notes2tex.git
cd notes2texCreate a .env file in the project root (this file is ignored by .gitignore and never committed):
GEMINI_API_KEY="your-gemini-api-key-here"(You can obtain a free Gemini API key from Google AI Studio. You can also provide the key directly in the web UI).
./start.shThis automatically initializes the virtual environment, installs dependencies, and launches both services:
- Web App Studio: http://localhost:5555
- FastAPI Backend: http://127.0.0.1:8008 (Interactive Swagger docs at
/docs)
- Open Chrome, Brave, or Edge and navigate to
chrome://extensions. - Enable Developer mode in the top right.
- Click Load unpacked in the top left.
- Select the
extension/folder inside thenotes2texrepository. - Open any project on Overleaf, open the Notes2TeX extension popup, upload a photo/PDF or click Inject Demo Sample, and watch the compiled LaTeX inject directly into your document.
- Zero Secret Exposure: API keys are never stored on external third-party servers. All requests are routed through your local backend instance or stored in your browser's local storage.
- In-Memory Processing: Uploaded images and PDF pages are processed in-memory (RAM) via OpenCV and
pypdfium2without persistent storage. - Sanitized Responses: Error handlers and logging pipelines automatically redact headers, credential keys, and environment variables.
MIT License. Created by Sumit Kumar.