Build a Zero-Trust Document Pipeline with OpenCV, Presidio, and LangGraph (Beginner Guide)
Description and use
The pipeline processes ID documents locally, removes PII before sending to an LLM, using OpenCV, Tesseract, Presidio, and LangGraph.
Problem
Sending raw identity documents to an LLM API exposes PII and creates a privacy risk.
Outcome
The pipeline processes identity documents locally, removes PII before any external API call, and provides a resilient, state‑machine based workflow.
Workflow
- Set up OS and Python environment with required libraries
- Preprocess ID images using OpenCV (grayscale, blur, adaptive threshold)
- Extract text from cleaned images with Tesseract
- Redact PII from extracted text using Microsoft Presidio and spaCy NER
- Orchestrate the steps with LangGraph as a state machine
- Expose the pipeline via a Streamlit frontend
Evidence
We will use local computer vision and NLP to intercept identity documents, extract the text, and deterministically mask Personally Identifiable Information (PII) before it ever reaches an LLM.
If you default to the large model (~580MB), your app will likely suffer from Out-Of-Memory (OOM) crashes when deployed on free cloud tiers.
- Record date: 2026-10-07T11:41:20.087Z