Open cilynx opened 1 year ago
I have this working pretty well in a stand-alone script borrowing, correcting, and updating code from:
https://dontrepeatyourself.org/post/learn-opencv-by-building-a-document-scanner/ https://pyimagesearch.com/2014/08/25/4-point-opencv-getperspective-transform-example/
Why all these tutorials resize all images to the same aspect ratio regardless of source and then transform and dump out a squashed grayscale version, I'll never understand. Find the corners on a smaller version where you can control the blur kernel vs document resolution sure, but perform the transform on the original.
Still pondering how to implement this -- e.g. should this automatically run on every import? only jpgs? How do we handle reprocessing (#18)? What about multiple documents? Can we use the same edge detection routines to do #3 instead of sorting out whatever they're doing at the linked repo over on that one?
If I had a GUI grid/list working, I'd say this should be a one-shot option on a context menu.
What about multi-page documents? What if there are multiple pages in a single photo? What about constructing a multi-page document by selecting several images to import at once?
Maybe we should run this on every import, even straight off the scanner bed to handle garbage like skew, page size not matching scan size (#20), etc.
There are a lot of times that I want to get a document into my library but all I have is my phone camera. Extracting a "good enough" document from crappy phone pictures is pretty much a solved problem these days, so we should support it.