Edge detection & preprocessing
On-device, native C++ / OpenCVContour detection locates the page. Affine homography transformation corrects perspective and skew. CLAHE — Contrast Limited Adaptive Histogram Equalization — normalises contrast locally rather than globally, which is what recovers a faded carbon copy photographed under a single tube light without blowing out the parts that were already legible. This stage runs before anything is read, and it is the largest single accuracy lever in the pipeline.