Step #1: Gather the PartsPrevNext
- For this project you'll need the following:
- In this project we use the EV3 system. However, the project can be done with the NXT system as well. You can also order the part set by using our Lego Digital Design Files: a full Bill of Materials can be produced with the software.
Step #2: Build the BookreaderPrevNext
Since we wanted to use the Raspberry Pi camera, the BrickPi and Raspberry Pi setup had to be placed above the book to get a good picture of the page. The structure that we ended up with looks a bit like a lean AT-AT walker from Star Wars.
The Camera is Placed Squarely Above the book.
In our example, we used the Lego Mindstorms EV3 kit.
The trickiest part of setup lies with the motor connected to the wheel. The motor is not fixed to the platform, but can rotate freely from the point that it is connected to the platform. This is important because it keeps the pages pressed down so that the wheels can get a grip on the page. Another important thing to do is to rotate the wheel only for the time it takes for one page to come out of the wheel, then rotate the wheel back so that any extra pages that might have been pulled up are brought down.
A closer look at the page turning mechanism.
In the Dexter Industries Github Code Repository, there is a test code called arm⎽test.py to help you calibrate the arm for perfect movement. Connect the motor to Port A of BrickPi and change the values of ‘speed⎽roller’, 'speed_arm, 't1' and ’t2’, until you get flawless movement of your book pages.
Step #3: Set Up the CameraPrevNext
Raspberry Pi Camera mounted with Lego.
The Raspberry Pi camera packs a lot of punch: there are a lot of options; it’s easy to set up; and the image quality is acceptable for our project. We held it in place by pinching it between two Lego Technic beams in the previous section.
After connecting the camera, there is one more thing to do: change the focus of the Raspberry Pi camera. The camera comes with its focus fixed at infinity, and since it is a fixed focus camera, you have to manually change it. Here are two helpful links to do focus the camera:
After setting up the camera, take a test image to see that it is properly focused. In the rig we built, we have the camera about 10 inches above the book. (You may need to adjust the height depending on your book size.)
To take a test picture, simply run "raspistill -o image.jpg"
Take a few test images to check if the images are clear and the whole page is captured. If the camera is initialized properly you’ll see a new file image.jpg in your present folder. Open it to see the image.
You may need to readjust the focus of the camera and angle at this point.
Step #4: Set Up the Text To Speech SoftwarePrevNext
First we'll setup the Text-To-Speech engine (TTS). TTS takes text data and reads it aloud. In our project, we use eSpeak. The voice is robotic, but using eSpeak, we can select a few accents and choose the gender of our reader.
First, test if the audio is working on the Raspberry Pi. Plug a headphone or speakers in the audio jack and run the following command:
If you are able to hear the sounds, move to the next step. If not, this tutorial may help you set up the audio.
Now, install eSpeak. Run the following in terminal:
sudo apt-get install espeak
After it is successfully installed, run the following command (disregard any error messages on the terminal if you can hear sound):
If you are able to hear “hello” from the headphones or the speakers, move to the next step.
Step #5: Setup the Optical Character Recognition (OCR) EnginePrevNext
Optical Character Recognition is really cool; it can read a picture of text, and turn it into text on the computer. We chose Tesseract OCR Engine. It runs smoothly on the Pi, it does not require an online connection, and it reliably converts images to text.
First, install tesseract:
sudo apt-get install tesseract-ocr
Next, test the OCR engine. Take a good image of a piece of text and run tesseract:
tesseract image.jpg o
Image.jpg is the image which was taken by the raspberry pi camera and o is the file in which the text will be saved (tesseract will make it o.txt, so no need to add the extension).
Now, wait. The OCR takes a lot of processing power. When the Pi is done processing, open o.txt. If the OCR did not detect anything at all, you can try rotating the image and running the tesseract again.
Step #6: Put it All Together: Digitize a BookPrevNext
With the camera, software, and platform working it is now time to bring the Bookreader to life.
Download the program bookreader.py from the BrickPi GitHub Python Repo and put it in the directory where you have the BrickPi.py library. Run the code to bring it to life:
And start digitizing the worlds millions of books!
Like the Bookreader project? The BrickPi is an opensource hardware and software project. You can contribute to the GitHub repository for the BrickPi and make it better!