Laser Scan Methods

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

Moderator: peterZ

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

Re: Laser Scan Methods

Post by duerig »

The current method works well most of the time. But there are two defects.

First, it takes a lot longer to scan because we are taking twice as many pictures and this means that each set takes at least eight or ten seconds. So there needs to be more investigation into whether one laser scan can work on multiple images.

Second, using the laser dewarp and then the auto dewarp, we get good results most of the time. But it since it still uses the auto dewarp heuristic, it can fail on some pages. I would like to come up with a way to avoid the heuristic.

I think that laser methods will work best on small books. These tend to have a much greater tendency to close on every page turn if you are using a scanner with a platen. And they are usually much easier to keep consistently open and avoid issues where the top is more curled than the bottom.

Let me get you links to the papers I mentioned.
duerig
Posts: 388
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: Laser Scan Methods

Post by duerig »

Useful papers on dewarping images that are relevant to lasers:

A 'competition' among various techniques of dewarping: http://www.csse.uwa.edu.au/~shafait/pap ... BDAR07.pdf

A model based method that requires two curves (top and bottom) and two straight lines (left and right) like ST does: http://www.imlab.jp/cbdar2007/proceedings/papers/P1.pdf

The above is an elaboration of a model that just requires two curves:

http://citeseerx.ist.psu.edu/viewdoc/do ... 1&type=pdf
http://lear.inrialpes.fr/people/triggs/ ... 28_cao.pdf

In theory, either one of the above models could be used with the laser position data as a curve instead of their line-detection heuristics.

One persistent problem is coming up with the 'straight' lines of the text. ST and others use heuristics that assume that the left and right edges will be justified. Are there ways to detect the shape of the page more directly to determine that line?
guitarguy
Posts: 7
Joined: 12 Sep 2014, 11:44
Number of books owned: 0
Country: Germany

Re: Laser Scan Methods

Post by guitarguy »

So there needs to be more investigation into whether one laser scan can work on multiple images.
I'm not sure if that will work. I guess two pages have to be aligned very well in order to use the same laser image? Although I have no practical experience, I think it would be really annoying if you have to be that careful when turning pages.

I still believe a high level of automation is necessary to get a satisfying speed. For example a foot switch that after being pushed will turn on the laser, triggers the camera, turns turn off the laser and turns on the lights and finally takes the second shot.
I think that whole process should not take longer than 3 seconds? If the camera has a short delay between the shutter being pressed and the shot actually taken (sorry, I can't remember the correct technical term, it's called "Auslöseverzögerung" in german).




Thank you for the links to the papers. I found a few, too.
No dates in most of them, really annoying. And there are all referring to each other.

I found the paper "winning" the contest by the University of Kaiserslautern (the CTM-method) and I found a paper by the organizers of the contest. They say they found a method working even better than CTM.

I hope tonight I have the time to look at it and get you the link.
duerig
Posts: 388
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: Laser Scan Methods

Post by duerig »

On my rig, I have Spreadpi setup to automate everything. But the time to take and transfer each picture is four seconds. Each shot, it first turns out the lighting and turns on the lasers taking one shot. Then it turns on the lights and turns off the lasers to take a second shot. Each shot takes four seconds for eight seconds total.

If you have a raspberry Pi, I can help you get a similar automated setup. You use the powertail switch described above to control the light and the lasers can be wired up to a five volt source with a transistor controlling each one.

Now if I had nice dslr cameras then it might go quicker. :) And Johannes is working on an update that will shave half a second off of each shot.
guitarguy
Posts: 7
Joined: 12 Sep 2014, 11:44
Number of books owned: 0
Country: Germany

Re: Laser Scan Methods

Post by guitarguy »

Okay, maybe I am spoiled because I have a DSLR.
If you have a raspberry Pi, I can help you get a similar automated setup.
Thank you! I don't have one yet, but it sure sounds interesting.



The papers by the group in Kaiserslautern turned out to be unsuited.
The first one focused on text line recognition, the second one on objective, measurable methods to compare dewarping technologies. (That one might be interesting later.)



I'll have a look on the paper you've linked to, called "A Model-based Book Dewarping Method Using Text Line Detection" of the University of Peking.

And I have to questions:

Number one: The only line laser I have is meant to be a replacement for a water level, but it did okay for a few experiments. When the laser is perpendicular to the page, it forms a straight line, even if the page is warped.
If the laser gets more parallel and less perpendicular to the page (what a brilliant phrase, mathematically speaking :D), the more distorted the line gets.

Do you consider the angle between laser and page in your algorithm?

And the second question:
When you did interpolation, how did you store (I hope that term's correct, maybe "save" is better?) the image? Discrete values, for example a matrix? Or some kind of continuous model?
I started to implement described here: http://www.leptonica.com/dewarping.html
But in the end I had polynomials to fit data points and polynomials for interpolation. When I wanted to calculate the new position of the pixel for example x=10, y=10, it should get 5,67 pixels lower. Not very useful.
I couldn't round either, because than two different pixels would end up at the same position.
duerig
Posts: 388
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: Laser Scan Methods

Post by duerig »

For your first question, you will need at least two lasers. I would recommend buying several from the dx.com site mentioned earlier in this thread. For simple experiments, you can attach them to batteries to manually position them. And then later on, if you get a Pi or similar controller, you can wire them into a breadboard for automation prototyping. I have five because this will let me try out more configurations to see if there are improvements with more lasers.

In terms of the angle of the lasers, I am currently placing them perpendicular to the page offset from the camera in either direction. If you do this, you will note that it follows the line of text on the page. In terms of the papers I pointed to (and ST), this means that the line can serve as a replacement for the line-detection heuristics.

But, it may be the case that placing them at an angle may give us better height information which can be used with some other technique. The current line-detection techniques are, after all, designed to dewarp with information that they had (line layout on a page) and laser lines might be able to provide more information about height than the text lines. The original trials that Dan and anonymous2 tried were with lasers at 45 degrees relative to the plane of the book.

On the second question, there are two pieces and I got both of these ideas from Tulon on another thread somewhere. First, you want to end up with a mapping that lets you start with transformed coordinates and get the 'old' coordinates:

Code: Select all

x_old = some equation involving x_new and y_new
y_old = some other equation involving x_new and y_new
What this means is that you might end up using the same 'old' pixel in multiple different locations in the 'new' image. But you will never have gaps.

The second piece is that if you end up with fractional values in your mapping, you can take the pixels around that location, average them out, and use that average color value as the new color value. And you can weight the average based on the proportion of the original pixel covered by your fractionally offset one.

As a first pass, I would just round the value and see what it looks like. And then use the sub-pixel color weighting stuff if/when things look good on a macro scale and you want to start improving the fine details.
dpc
Posts: 379
Joined: 01 Apr 2011, 18:05
Number of books owned: 0
Location: Issaquah, WA

Re: Laser Scan Methods

Post by dpc »

duerig wrote: ...

On the second question, there are two pieces and I got both of these ideas from Tulon on another thread somewhere. First, you want to end up with a mapping that lets you start with transformed coordinates and get the 'old' coordinates:

Code: Select all

x_old = some equation involving x_new and y_new
y_old = some other equation involving x_new and y_new
What this means is that you might end up using the same 'old' pixel in multiple different locations in the 'new' image. But you will never have gaps.

The second piece is that if you end up with fractional values in your mapping, you can take the pixels around that location, average them out, and use that average color value as the new color value. And you can weight the average based on the proportion of the original pixel covered by your fractionally offset one.

As a first pass, I would just round the value and see what it looks like. And then use the sub-pixel color weighting stuff if/when things look good on a macro scale and you want to start improving the fine details.
What you've described is common texture mapping using bilinear filtering and is handled quite efficiently using a GPU via Direct3D or OpenGL.

BTW, thanks for the tip on buying lasers from dx.com. I needed a cheap laser to help verify my camera tilt is set perpendicular to the platen on a tripod and I managed to find something cheap to fit my needs.
dtic
Posts: 464
Joined: 06 Mar 2010, 18:03

Re: Laser Scan Methods

Post by dtic »

duerig wrote:On my rig, I have Spreadpi setup to automate everything. But the time to take and transfer each picture is four seconds. Each shot, it first turns out the lighting and turns on the lasers taking one shot. Then it turns on the lights and turns off the lasers to take a second shot. Each shot takes four seconds for eight seconds total.
Four seconds sounds a bit slow. I think Spreads uses chdkptp but I'm not sure if it uses the newer remoteshoot (rs) command for chdkptp that speeds up the shots significantly by allowing the next shot to proceed while the previous shot is being saved. See chdkptp helpfile for command syntax. chdkptp is easy to control over the command line.
duerig
Posts: 388
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: Laser Scan Methods

Post by duerig »

Dtic, Spreads does use remote shoot, but it definitely isn't taking advantage of this. I will definitely look more into how to do this. To make it work well, I also need to figure out how to my code can determine whether or not the remote shoot has actually completed. And how to determine when the cameras are actually ready to capture again.

Also, if there is a limitation on how many remote shoot transfers can happen at once, this could be important. If a fast scanner has been taking pictures every three seconds while they take four seconds to transfer, you can imagine that after a few hundred pages, the queue will be large.

However, even if there is a limitation on the number of queued shots, this would still be very useful for laser scanning.
guitarguy
Posts: 7
Joined: 12 Sep 2014, 11:44
Number of books owned: 0
Country: Germany

Re: Laser Scan Methods

Post by guitarguy »

Thanks for the in-depth answers! Now things get clearer for me.
However, I won't continue my first experiments. I don't think that would be useful.

If I understand correctly, there are two basic groups of interest:

1. Algorithms that straighten text-lines. We would use a line created by a laser instead.

2. Algorithms that actually create a 3D-model of the page and the mapping is a projection to a 2D rectangular surface.

This method (http://www.imlab.jp/cbdar2007/proceedings/papers/P1.pdf) you've linked to sounds good to me. Should we try to implement it? That would be a method of group 1 and later we could try a method of group 2.


Oh, and before I forget: dx.com seems to be great. Free world-wide shipping, I'm impressed. Maybe I will ask for you help when I set up a shopping list ;-)
Post Reply