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

Spread Processor as Chroot on Android devices

Johannes Baiter's Spreads and SpreadPi are the latest control systems and postprocessors for DIY scanning. http://spreads.readthedocs.org
boredland
Posts: 42
Joined: 08 Jan 2014, 07:30
Number of books owned: 0
Country: Germany

Spread Processor as Chroot on Android devices

Post by boredland » 14 Jun 2015, 14:43

Hi there,

some days ago I had an idea: What if one could run a processing instance of spreads on a tablet or smartphone running android.

I saw people running chrooted systems on their android devices for various reasons. Most of the time they installed Ubuntu or Kali running a VNC-Server, so they could use an android VNC-client in their chroot. That worked surprisingly well.

So I looked at what a spreads processor needs. Basicly: multiple CPU-cores for Tesseract and the last step in ScanTailor, at least 1-2gb of free ram (the buggy pdfbeads sometimes needs more, but thats another story), networking, space for the files and well, a running debian-based system.

My Tablet, a cheap Pipo p7 with an rk3288 quadcore-processor and 1-1.5gb free ram (a lot of apps installed though..) seemed to fullfill all those things (http://www.pipo.com/product.php?id=170).

So in the next step i looked for how to easily create a chroot. There are several apps to achive this. From my impression the app "linux deploy" (https://play.google.com/store/apps/deta ... ploy&hl=en) seems to have some features that could reveal to be quite useful:
installing an debian chroot, booting it up on android boot, and using an sd-card-partition as chroots rootfs.

I installed that app and got me an debian jessie on the sd-card (using the app). Those are my preferences:
https://drive.google.com/file/d/1bnj9z5 ... sp=sharing
https://drive.google.com/file/d/18qDGVU ... sp=sharing
https://drive.google.com/file/d/1Ot_NS1 ... sp=sharing
https://drive.google.com/file/d/12wzYwE ... sp=sharing
https://drive.google.com/file/d/1wVVUAI ... sp=sharing

If you want to check what the dev-path for you sd-card is, use an android terminal tool (https://play.google.com/store/apps/deta ... term&hl=en) and get the list of devices by typing 'fdisk -l', 'mount' or 'cat /proc/partitions' (I think one of them should work). I recommend formatting the device with ext3 or ext4 before, so you don't have to fiddle around with the device being mounted in android.

After some time installing (press on the install-button), linux deploy will serve a debian-chroot, available via ssh under the IP in the upper left corner of the window. From there you can easily install all the spreads software (It may be a good idea to do this on another machine as crosscompile, as I did, or chrooting it there, since this will take some time). A good hint for compiling all the software (tesseract, pdfbeads, djvubind etc. etc.) is the spreads-deploy repository, which you mostly can use for copy and paste (https://github.com/boredland/spreads-deploy).

After that I added some init-job, edited the configuration (the port 5000 was for some reason locked so I changed it to 2060 in my chroot and raspberry, as I added the processor in the configuration of my raspberry.

Now I did hit the stop and start button in linux deploy and got to the page of my spreadpi (192.168.0.107 in my case) and did shoot some pages. I did sent them to my chroot-postprocessor and well: I works. Not as fast as I hoped (2 minutes for 8 pages), but that can be optimized (more free ram a.s.o.). I had several errors on my spreadpi and during postprocessing. The are spreads-related (I think) and I already issued them on Github.
https://drive.google.com/file/d/1WyVRGm ... sp=sharing

If you want to give it a try, I uploaded my image. dd it to your sd-card and extend it in size. It is quite big, since I didn't install anything needed for compiling. Just take the settings from above, set the correct device and hit start.

https://drive.google.com/file/d/0B5FaJb ... sp=sharing

Future:
[*]I think there are possibilities for chroot to take over control over periphal devices. I didn't try yet but I think it could be possible to get the chroot to access cameras connected to the tablet, as well as the footpedal.
[*]I think adding a swapdrive would be neat
[*]Perhaps installing the image to a usb thumbdrive would be much faster (since nearly all sd-drives in tablets and phones are shit). I didn't try yet, but afaik my tablet seems to support that.
[*]I think it'd be possible to compile tesseract in OpenCL on my tablet. The needed sources seem to exist already.

What do you think about this approach? Is it worth following up with?

Yours,
Jonas

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

Re: Spread Processor as Chroot on Android devices

Post by duerig » 14 Jun 2015, 16:32

There are two interesting possibilities here, IMO.

First, is it possible to get your tablet to control cameras via USB? Maybe with a USB hub? If so, the tablet running spreads could act as an all in one interface for a scanner. the current method of using a Pi is doesn't get us there. The Pi is headless so the user has to use a browser in a separate tablet or their PC for control. I was looking at how expensive touch screen displays for a Pi is for just this reason. But a tablet is probably cheaper and more compact than a Pi plus a DIY touchscreen.

Second, maybe this could work really well on a tablet with a good camera instead of relying on external cameras. You would have to design the scanner with this mode of operation in mind to make it work, though.

If the android tablet can do post processing as well as everything else in one package, that would be icing on the cake. It would be awesome to come up with a true plug and play controller that an average person can use without knowing anything about Linux or networking or IP addresses.

-D

boredland
Posts: 42
Joined: 08 Jan 2014, 07:30
Number of books owned: 0
Country: Germany

Re: Spread Processor as Chroot on Android devices

Post by boredland » 14 Jun 2015, 16:48

I think using the chroot for shooting and everything is possible, with a hub. Expensive touch displays for decent devices (in my case the firefly rk3288) were the reason I looked for this method at first. I think the best method would be implemented on a tablet featuring linux. I think the Pipo P7 at $140 is a good base for that, since there's already a kernel source for the firefly and they share a lot of hardware. Sadly my progress in this path isn't measurable. For now I'll try to fetch the usb-devices in the chroot.

Using a tablets cameras for shooting is an idea I can't really imagine to use (perhaps my phantasy it limited to the current built..).

boredland
Posts: 42
Joined: 08 Jan 2014, 07:30
Number of books owned: 0
Country: Germany

Re: Spread Processor as Chroot on Android devices

Post by boredland » 14 Jun 2015, 18:38

Well. Not kidding:

I installed the depencies for chdk, just plugged in a usb-hub. then added a camera. android popped up, asking me what to do with it. I just ignored that, and ran spread configure. after that I repeated that for the other camera:

IT WORKS!!

The Footpedal, the cameras... its awesome!

Image

Image

Image

Image

Image


Just a little thing (nothing to do with spreads): the usb-hub and cameras plugged, my touchscreen is unusable. It needs grounding. When leave my hand on the backside of the Pipo the touchscreen works. Else it touchs everywhere but where i touched...

boredland
Posts: 42
Joined: 08 Jan 2014, 07:30
Number of books owned: 0
Country: Germany

Re: Spread Processor as Chroot on Android devices

Post by boredland » 14 Jun 2015, 19:27

I fixed the grounding-issue with a big strip of aluminum serving tray laid into the tablet-holder and a cable connecting it to one of the screws of the lamp. Not very nice, but works.

Does someone know an app that does 'nothing', when a Camera gets connected? My tablet asks if I want to use the gallery or the google photos app. I permanently want to use 'nothing'. There's an app for keyboards (nullkeyboard) that does exacly this for keyboards. The same for cameras would be neat...

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

Re: Spread Processor as Chroot on Android devices

Post by duerig » 14 Jun 2015, 20:15

That is awesome! Can you tell me more about the issue with grounding? Is it just a problem with your particular tablet? Why does it happen when you plug in cameras?

I notice on your screenshot that you are still using an IP address. Can you use localhost as well? One issue I want to solve is that currently there is a cumbersome and unfortunate step of typing in a random IP address when talking to Spreads on a Pi.

I think I may have to get a Pipo P7 tablet myself soon and try it out!

How easy is this to package? Could we create an SD card and put it in a P7 and hand it to somebody with no linux knowledge and have them scanning in a minute or two?

-D

boredland
Posts: 42
Joined: 08 Jan 2014, 07:30
Number of books owned: 0
Country: Germany

Re: Spread Processor as Chroot on Android devices

Post by boredland » 15 Jun 2015, 02:28

duerig wrote:Can you tell me more about the issue with grounding? Is it just a problem with your particular tablet? Why does it happen when you plug in cameras?
I have no idea. Perhaps I can try that next week with a galaxy tab...
duerig wrote:I notice on your screenshot that you are still using an IP address. Can you use localhost as well? One issue I want to solve is that currently there is a cumbersome and unfortunate step of typing in a random IP address when talking to Spreads on a Pi.
I tried with localhost:2060 - no problem.
duerig wrote:I think I may have to get a Pipo P7 tablet myself soon and try it out!
How easy is this to package? Could we create an SD card and put it in a P7 and hand it to somebody with no linux knowledge and have them scanning in a minute or two?
-D
Since its a Chroot its very easy to reproduce, we can just take the spreadpi buildroutine and modify it for the debian-rootfs. Moreover if the kernel supports loop-devices (and the Pipo Ones does) we can just let the user copy the .img-file onto his internal sd. That will even be a little bit faster. In the next days I'll write a step-by-step guide to get it running.
I think with a proper guide and uniquely for some tested devices, this will be easy for users to reproduce.

In a step more far away: Many of the chroot-apps out there are OpenSource. I think someone with java-skills not as stubby as mine will be able to modify it to preload our image and preconfigure it properly. That will make it even easier.

boredland
Posts: 42
Joined: 08 Jan 2014, 07:30
Number of books owned: 0
Country: Germany

Re: Spread Processor as Chroot on Android devices

Post by boredland » 15 Jun 2015, 08:07

boredland wrote:Does someone know an app that does 'nothing', when a Camera gets connected? My tablet asks if I want to use the gallery or the google photos app. I permanently want to use 'nothing'. There's an app for keyboards (nullkeyboard) that does exacly this for keyboards. The same for cameras would be neat...
Perhaps my brother will write that for us ;)

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

Re: Spread Processor as Chroot on Android devices

Post by duerig » 15 Jun 2015, 09:39

When you post your step-by-step guide, I'll try to see if I can get it running on an old first-gen Nexus 7 I have lying around.

boredland
Posts: 42
Joined: 08 Jan 2014, 07:30
Number of books owned: 0
Country: Germany

Re: Spread Processor as Chroot on Android devices

Post by boredland » 16 Jun 2015, 04:14

Salukstra created a an app for us, that can be selected as default handler for the cameras. This way you get rid of the annoying android-popups:
https://play.google.com/store/apps/deta ... a.usbdummy

Please give him a good feedback, I'll send him a bunch of beers ;)

Post Reply