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

Laser Scan Methods

DIY Book Scanner Skunk Works. Share your crazy ideas and novel approaches. Home of the "3D structure of a book" thread.
duerig
Posts: 360
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: Laser Scan Methods

Post by duerig » 18 Sep 2014, 16:57

I have some Python code that ostensibly implements the method in that paper. But it produces crazy results and I don't understand the math well enough to know what I am doing wrong. Send me a PM with your email address and I can send you the code I have if you want to look at it.

For testing, you can run it against the samples that I posted earlier in this thread.

guitarguy
Posts: 7
Joined: 12 Sep 2014, 11:44
Number of books owned: 0
Country: Germany

Re: Laser Scan Methods

Post by guitarguy » 18 Sep 2014, 17:34

I'll send you a PM.

duerig
Posts: 360
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: Laser Scan Methods

Post by duerig » 23 Sep 2014, 00:48

I've been working with Cristoph over the last few days, and we have some very promising leads on new methods. The most promising method at the moment lets us dewarp pictures in a manner that is completely content-independent.

Take a look at this paper: http://users.iit.demokritos.gr/~bgat/3337a209.pdf

The 'coarse' method from the paper is simple enough mathematically that I have been able to implement it to try it out. The test scans I have made with it look very good. But I need to make some changes to my laser scanning rig and re-run the scans before I want to declare victory and post the pictures here.

My test script has expanded into something fairly capable and I have put it up on github at: https://github.com/duerig/laser-dewarp

If you are interested in setting up a testing rig and want to use the script, let me know and I can help you make everything work. Also, if you are knowledgeable about Python optimization, get in touch. One of the few disadvantages to my current script is that it takes about a minute per page in low quality mode and about five minutes per page when doing high quality bilinear interpolation when sampling the original image.

duerig
Posts: 360
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: Laser Scan Methods

Post by duerig » 30 Sep 2014, 10:34

Now that enough pieces of the laser scanning technique are working, I can now see a viable end to end workflow.

## Rig:

The rig is essentially a copy stand with attached lasers and lighting. A single camera faces down on the page with two lasers pointing straight down at adjustable positions. The lasers should be near the page edge, projecting down about half an inch from the top and bottom of the page edge. Bigger books should have the lasers further away from the camera. Smaller books should have them closer.

Control is done via the GPIO pins of a Raspberry Pi. It controls three switches, two of them are P2N2222A transistors, the third is a PowerTail II power controller. The two transistors each control a laser and the PowerTail controls the AC plugs for lighting.

The base of the copy stand must provide a black background for your scans. Use black posterboard here.

## Callibration:

(a) The user finds the right focus and other camera settings and locks them in.
(b) Take a photo with lights on and lasers off of just the background.
(c) Take a photo with lights on and lasers off of your hands resting on background. Curl your hands and put your thumbs straight up. As if you were holding an imaginary book. This should get skin area that is likely to be captured while holding a book. Some of your skin will be in shadow and other not. This picture will form a hand model for finger and hand detection.

## Capture:

(a) Open the book and cradle it in your hands. Try to keep the pages straight. It should be roughly centered under the camera and positioned so that both lasers hit it. It is fine if lasers hit your hands or arms to the side, but try not to hold it where the laser is on the page.
(b) Trigger the next capture stage, holding the book still.
(c) The lights go off, the lasers come on, a laser shot is captured.
(d) The lights come on, the lasers go off, a scanning shot is captured.
(e) You turn the page.

## Processing:

(a) Using the background and hand photo from callibration, a mask for the whole book is generated.
(b) The laser shot on the book (non-book lasers light is ignored) is analyzed to determine the edge of the page and where the spine is.
(c) The page edges and spine give us left and right edges to make vertical. The curves of the lasers give us arcs to straighten. These are used by the laser-dewarp model to create a rectified page.
(d) We can use the same model to rectify the whole book mask. This can be used to crop the dewarped image to the page.
(e) Now we have a set of cropped, square whole page images. This can be passed to a tool like ST for automated content select and binarization or bound into a pdf or djvu file.

duerig
Posts: 360
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: Laser Scan Methods

Post by duerig » 26 Oct 2014, 18:01

Now that I'm happy with the results (see results thread), I wanted to show you a few videos describing the workflow and the Mk. IV laser scanning rig.

Rig: https://vimeo.com/110082516
Callibration: https://vimeo.com/110081638
Capture: https://vimeo.com/110087112
Processing: https://vimeo.com/110086045

This should give you an overall picture what what laser scanning actually looks like from start to finish right now.

jlb
Posts: 5
Joined: 08 Jun 2014, 15:51
Number of books owned: 0
Country: France

Re: Laser Scan Methods

Post by jlb » 29 Oct 2014, 11:23

This project looks very interesting. I have a Raspberry and I want to try it. Could you give me the electrical diagram ?
Thanks. Jean-Louis.

duerig
Posts: 360
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: Laser Scan Methods

Post by duerig » 29 Oct 2014, 11:37

I will work on getting something more formal, but the electric diagram is extremely simple. For each laser, you just have:

+5v --> (collector) NPN 2N222A transistor (emitter) --> Laser --> Ground

With one of the Pi's GPIO pins attached to the base of each transistor.

The power tail II which controls the lights is even simpler:

GPIO Pin --> PowerTail II -> Ground

Then you turn on the pins in software to activate the appropriate laser and/or the lights. I use the gpio command line from WiringPi: http://wiringpi.com/

jlb
Posts: 5
Joined: 08 Jun 2014, 15:51
Number of books owned: 0
Country: France

Re: Laser Scan Methods

Post by jlb » 31 Oct 2014, 06:25


duerig
Posts: 360
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: Laser Scan Methods

Post by duerig » 31 Oct 2014, 11:05

Thanks for the link. I am still struggling with the math. The capture method seems to be similar to mine, though looking at their laser shots makes me think their lasers are at a slight angle rather than pointing straight down.

From what I can understand of their math so far, their dewarping method seems to be much more solidly based in the actual geometry. If and when I understand it well enough to implement it, I will be very interested to see how the results compare with the method I am using.

There are four ways in which their method might provide an improvement over the current dewarping algorithm:

(1) It might just look better (hard to quantify) or be more accurate
(2) It may obviate the need for my 'stretch-factor' parameter entirely by automatically removing foreshortening
(3) My method only works for lasers pointing directly down. Their method might work for lasers at various angles. If so, that might allow better/simpler designs for a capture rig.
(4) Their method might handle document skew better than the current algorithm. I think I handle skew ok, but there may be room for improvement.

Figuring out if any of these improvements pan out means really understanding the math behind it. jlb (or anyone), if you have expertise in this regard to contribute, please let me know here or via PM. I'd love to talk it over with you and I'm sure that Christoph would as well.

mhr
Posts: 37
Joined: 07 May 2012, 10:12
E-book readers owned: onyx-boox-m92 sony-trs-t1
Number of books owned: 500
Country: Germany

Re: Laser Scan Methods

Post by mhr » 05 Dec 2014, 06:25

I've no deep knowledge in optics, but I've heard about polarization filters.
Is it possible to use polarization filters for the light bulbs and others with
90 degree rotation for the lasers. Then You might use two cameras with
another set of polarization filters (rotated by 90 degrees) mounted next to each other to obtain
both pictures in one shot without the neccessarity to turn off/on the light bulbs
on each page. Of course the dewarping might have to take into consideration the different
viewing positions of the two cameras.

I don't know if polarization filters and lasers work well together. Also the light bulbs might need big filters which aren't available. And You need six polarization filters and one additional camera. This might be costly.

Another option would be to use one camera, take two shots and after each shot the polarization filter in front of the camera is rotated by 90 degrees with some mechanism.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest