piscanner project

I have used a Raspberry Pi credit-card computer ($45), a camera module ($25), two picture frames, two light bulbs, some wire and tape to make a book page scanner that can non-destructively capture page images of a book without destroying the book to get individual leaves or even needing to open the book up more than 90 degrees. Here is how I made my piscanner:

  1. Take two 8 x 10 picture frames. Remove the glass from the frames.
  2. build a "crate" with the picture frames with one pane of glass between the frames on the front and the other on the top.
  3. put a piece of white paper on the top glass to the camera will not see text on the page that will be sitting on the top glass
  4. put two light bulbs on either side of the crate
  5. tape the Raspberry Pi to the top of a paint can
  6. use a paint stirrer stick to mount the camera module so it "sees" the front glass.
  7. write a simple Python program to turn on the lights, take a picture of a page, and save the image. (see code below)
  8. in production, use a black cloth to cover up anything that might reflect in the glass.

Here is the Python code to run the camera to take successive page images as the book is placed on the glass and pages are manually turned:

from picamera import PiCamera
from time import sleep

import RPi.GPIO as GPIO  # Import GPIO Module
GPIO.setmode(GPIO.BCM)  # Configures how I am describing pin numbering
GPIO.setwarnings(False)  # Disable Warnings
pin = 22 # this goes to a relay that controls the lamps

camera = PiCamera()
camera.resolution = (2592, 1944)
camera.framerate = 15
# camera.awb_mode = 'incandescent'

i = 1
GPIO.setup(pin, GPIO.OUT)
while i < 1000:
	GPIO.output(pin, True) # turn on lights
	camera.start_preview()
	sleep(5)  # required for autoexposure to balance
	print("capturing image") # turn page after seeing this message
	camera.capture("/home/pi/Desktop/c/image{:03d}.png".format(i))
	i += 1
	camera.stop_preview()
	GPIO.output(pin, False) # turn off lights
	sleep(1)

Images are scanned at a resolution that is more than sufficient for the OCR that I use. (I scan with both Abbyy and tesseract and merge the OCR results). Here is a page image from the piscanner. Click on the image for the full-sized page image.