Daniel Reetz, the founder of the DIY Book Scanner community, has recently started making videos of prototyping and shop tips. If you are tinkering with a book scanner (or any other project) in your home shop, these tips will come in handy. https://www.youtube.com/channel/UCn0gq8 ... g_8K1nfInQ

Methods To Sense The 3D Surface/Structure Of A Book

DIY Book Scanner Skunk Works. Share your crazy ideas and novel approaches. Home of the "3D structure of a book" thread.
Anonymous1

Re: Methods To Sense The 3D Surface/Structure Of A Book

Post by Anonymous1 » 24 Feb 2011, 13:36

If only I could figure out how to use PIL's ImageTransform function (PIL is Python's stripped-down image processing library), as it can input a mesh.

But it's horribly slow (OpenCV charges through the images in under a second, but PIL takes up those 10 seconds when doing the actual warping), so I'll have to play with OpenCV a bit more...

steve1066d
Posts: 296
Joined: 27 Nov 2010, 02:26
E-book readers owned: PRS-505
Number of books owned: 1250
Location: Minneapolis, MN
Contact:

Re: Methods To Sense The 3D Surface/Structure Of A Book

Post by steve1066d » 24 Feb 2011, 15:27

I was thinking about the camera calibration, and I think that using a checkerboard isn't a good idea (or at least not the best). I'm going to try to make a GUI application (or if one exists, I'll just use that) and manually dewarp a few images to find the distortion coefficients and the camera matrix.
You might want to check out Hugin:

http://hugin.sourceforge.net/tutorials/ ... n/en.shtml
Steve Devore
BookScanWizard, a flexible book post-processor.

User avatar
daniel_reetz
Posts: 2797
Joined: 03 Jun 2009, 13:56
E-book readers owned: Used to have a PRS-500
Number of books owned: 600
Country: United States
Contact:

Re: Methods To Sense The 3D Surface/Structure Of A Book

Post by daniel_reetz » 24 Feb 2011, 15:42

http://wiki.panotools.org/Fulla is the lens correction part of Hugin. You'll probably want the full Hugin interface to work with it at first. Spam and I were playing with Hugin for lens calibration - it's definitely doable, and there's a good tutorial out there by Bruno Postle (can't find it using my phone, unfortunately)

Anonymous1

Re: Methods To Sense The 3D Surface/Structure Of A Book

Post by Anonymous1 » 25 Feb 2011, 12:21

After playing with Hugin for an hour, I have concluded that it is not very useful for this sort of stuff...

The calibration produces worse results than what I get by manually doing it with a slider in GIMP. Dan, have you had any reasonable radial dewarping output come out of Hugin or it's CLI tools?

andigit

Re: Methods To Sense The 3D Surface/Structure Of A Book

Post by andigit » 27 Feb 2011, 02:53

Been so busy but wanted to share what I have for lens distortion correction so far...

Image
Larger: http://tanoshi.smugmug.com/photos/11997 ... mRze-O.png

The blue line are the deformed lines. I'm actually calculating backwards from what Anonymous and Steve are doing? This method actually makes it easer to do bilinear/bicubic operation easier since I know where the pixel for fixed x,y is coming from.

Haven't committed the code but I'm getting close... hopefully sometime in the next few days.

steve1066d
Posts: 296
Joined: 27 Nov 2010, 02:26
E-book readers owned: PRS-505
Number of books owned: 1250
Location: Minneapolis, MN
Contact:

Re: Methods To Sense The 3D Surface/Structure Of A Book

Post by steve1066d » 27 Feb 2011, 02:56

Actually, I'm doing the reverse warp.. Anonymous is doing the forward warp though.
Steve Devore
BookScanWizard, a flexible book post-processor.

TomHorsley
Posts: 96
Joined: 30 Jan 2011, 10:39

Re: Methods To Sense The 3D Surface/Structure Of A Book

Post by TomHorsley » 27 Feb 2011, 08:34

Anonymous wrote:As I don't have access to a machine with compiling capabilities (I'm on a Windows rig)
If you have the disk space and the bandwidth, you can download mingw and get a windows compile environment:

http://www.mingw.org/wiki/InstallationHOWTOforMinGW

(though as I type this, that link isn't responding, maybe the wiki is down at the moment).

Anonymous1

Re: Methods To Sense The 3D Surface/Structure Of A Book

Post by Anonymous1 » 27 Feb 2011, 22:05

That links isn't working for me either...

I'm back to my lovely Linux rig, so compiling is a breeze again. I'm probably going to switch to C++/C as soon as possible, as Python is getting a bit slow to run, and it's hard for people to use (binaries seems to be the stuff, even if they requires beating a dead horse multiple times).

I'm actually going to use your program, andigit. I was going to make one like that in Python and Qt4 (without the grid. I'm pretty bleh when it comes to GUI programming), but your C++ implementation seems to be pretty sweet (and I might as well steal your compiling code too; I can't figure out all this "make" nonsense, even though I've edited way too many Makefiles).

andigit

Re: Methods To Sense The 3D Surface/Structure Of A Book

Post by andigit » 27 Feb 2011, 22:40

Anonymous, Please do :) power of open source

And the barrel correction is finally alive!!! woot! The example is set at a extrem to show its working :)
Image
original: http://tanoshi.smugmug.com/photos/12007 ... 6dgg-O.png

The grid, lines up with top and the bottom image (corrected image on bottom).

Code isn't really clean but I got it pretty fast. Calculation and generating the image is almost instant now.

All the interpolation seems to be working. Right now I have nearest neighbor, Bilinear, and Bicubic implemented.

Sorry no binary but should be easy to compile. Was playing with exif data but I pulled the code out for now.

Anonymous1

Re: Methods To Sense The 3D Surface/Structure Of A Book

Post by Anonymous1 » 28 Feb 2011, 01:44

Yep, just a quick set of commands and it's up and running:

Code: Select all

git clone git://tanoshi.sourcerepo.com/tanoshi/BookCorrection.git andigit_dewarp
cd andigit_dewarp/BookCorrection/
mkdir build
cd build
cmake ..
make -j 4
./BookCorrection
The line detection is really good (mine used to die when the image had tons of noise, but a median blur filter took care of that), so the dewarping should benefit from that. The only big problem I faced was when I tried to load a full-sized image into your program: it froze for literally 5 minutes, and then loaded the image.

Your laser detection works really well. How do you do it (mine gets sloppy near the crease, and I can't read C++ very well, so I can't find out >.< )?

Post Reply