Image Processing
The processing pipeline uses OpenCV for deterministic on-device image enhancement.
Main processing function
Section titled “Main processing function”processDocumentImage(...) performs:
- Image decode from base64.
- EXIF/device orientation normalization.
- Optional center crop to camera preview aspect ratio.
- Quad point mapping from normalized coordinates.
- Perspective warp to flattened document output.
- Optional enhancement filter.
- JPEG encoding and file write.
Preview processing function
Section titled “Preview processing function”processImageFilterPreview(...) performs fast filtered previews without perspective warp.
Use it to keep edit UX responsive while the user toggles filters.
Filters
Section titled “Filters”Supported FilterMode values:
originalgrayscalebw
Detection characteristics
Section titled “Detection characteristics”detectDocument(...) evaluates multiple masks (edge + paper region), scores quad candidates by geometry/position, and returns the best contour when available.