I use Microsoft's "Office Lens" app on my Android phone all the time, like a "smart camera" which automatically squares off and white-balances each photo of a page (usually mail or forms filled in by hand). It can't handle warped pages though, so I hope they add something like this!
Page Dewarping
21–30 of 75 posts
Re: Page Dewarping
#22Earlier quoted context omitted.
Doesn't that describe most modern cell phone cameras?
I haven't heard of a phone camera that can do video at 120fps, they're usually 30, maybe 60 fps. The S7 has some high framerate slow-mo option, but it's limited to a 720p resolution.
Re: Page Dewarping
#23Is using a curve whose end points are fixed to zero to model the warping accurate? I can't see a rationale for why the end points should both be 0.
Re: Page Dewarping
#24Thanks for the feedback, everyone -- happy to answer questions here or in the Disqus comments on my blog.
This is really interesting, thanks! If you decide to try to make this faster, check out ceres[0] a non-linear least squares optimisation framework that does automatic differentiation using a clever C++ template hack. I've used it a few times to solve these kind of problems and found it to be very good! [0] http://ceres-solver.org/
Re: Page Dewarping
#25Earlier quoted context omitted.
Doesn't that describe most modern cell phone cameras?
I haven't heard of a phone camera that can do video at 120fps, they're usually 30, maybe 60 fps. The S7 has some high framerate slow-mo option, but it's limited to a 720p resolution.
Re: Page Dewarping
#26This is great! My wife is a music teacher and often scans sheet music so that it's more portable. She has been asking me for a while for something exactly like this. I'll have to tweak it to work on sheet music, since I imagine his methods to identify lines of text won't work for the music staff out of the box.
He mentions adding line detection for tables, which should be a good start for sheet music.
Re: Page Dewarping
#27Earlier quoted context omitted.
This is really interesting, thanks! If you decide to try to make this faster, check out ceres[0] a non-linear least squares optimisation framework that does automatic differentiation using a clever C++ template hack. I've used it a few times to solve these kind of problems and found it to be very good! [0] http://ceres-solver.org/
Yep, I'm still waiting to use ceres for something - I didn't end up using it on my image approximation project https://mzucker.github.io/2016/08/01/gabor-2.html because it doesn't work well with inequality constraints.
Re: Page Dewarping
#28This is great! My wife is a music teacher and often scans sheet music so that it's more portable. She has been asking me for a while for something exactly like this. I'll have to tweak it to work on sheet music, since I imagine his methods to identify lines of text won't work for the music staff out of the box.
You could also try ScanTailor: http://scantailor.org/
Re: Page Dewarping
#29I wonder if someone has tried to dewarp whole book from a video when flipping through it. I imagine that could be handy way to copy the whole book.
Re: Page Dewarping
#30Here is my very quick and dirty manual job of the same example page:
http://www.kylheku.com/~kaz/dewarp.png
Literally less than five minutes.
First I cropped the image. Then duplicated the layer. Blurred the top layer (Gaussian, 50 radius). Then flipped to Divide mode and merged the visible layers. This leveled the lightness quite well, almost completely eliminating the shadow over he right side of the page and all other lighting differences. There is a hint of the edge of the shadow still present because it is such a sharp contrast; but that can be eliminated in an adjustment of the intensity curves. In such cases it may be helpful to experiment with smaller blur radii, too.
I then did a perspective transform in the lateral direction, squeezing the left side top-bottom and expanding the right, resulting in the warp now being approximately horizontal. (The perspective transform is not just for adding a perspective effect; it is also useful reversing perspective!)
Finally, I used the Curve Bend (with its horrible interactive interface and awful preview) to warp in a compensating way. Basically, the idea is to draw an upper and lower curve which is the opposite of the curve on the page. I made two attempts, keeping the results of the second.
If the preview of this tool wasn't a ridiculous, inscrutable thumbnail, it would be possible to do an excellent job in one attempt, probably close to perfect.
Because the page is evenly light thanks to the divide-by-blurred layer trick, it will nicely threshold to black and white, or a narrow grayscale range.