PiTextReader - an Easy-to-Use Document Reader for Impaired Vision

5,557

41

23

Overview

Update: Short video demo: https://youtu.be/n8-qULZp0Go

PiTextReader allows someone with impaired vision to “read” text from envelopes, letters and other items. It snapshots an image of the item, converts to plain text using OCR (Optical Character Recognition) and then speaks the text using text-to-speech.

The Reader is designed to be as absolutely simple to use as possible. No Internet needed, no graphical interface, only one button. Just place the item to be read onto the stand and press a button. After a few moments, the text will be read back to them.

I designed this for an elderly parent with eye sight issues such as macular degeneration, but can be used more broadly for anyone wanting printed text translated into audio speech.

There are many readers available, most though, cost thousands of dollars or are for someone who is tech savvy requiring Internet connectivity and the use of a smart phone. This reader is designed to be completely standalone with no internet and no interface other than a large push button.

Pros

  • One button to control
  • No Internet connection required
  • No graphical user interface to navigate
  • Total cost less than $100
  • Always ready to go

Cons

  • OCR can be limited due to fonts, colors, text size, etc.
  • Speech sounds like Stephen Hawking
  • Works best for small sections of black text on white paper.

Step 1: Hardware

Step 2: Hardware Construction

Using the 8”x8” box:

1. Drill hole in the back for the power cord.

2. Drill hole on the front right corner for the momentary button
3. Drill hole(s) for the speaker. (see audio step 12 below)

4. I used a piece of 2”x1/4”x13” aluminum strip for the camera mount, but wood strips work too.

a. Mount the 8” flat wood strip on the back of the box LID. (be sure it is attached to the LID and not the bottom of the box, else you won’t be able to open it!)

b. Mount the 5” flat wood strip on top of the 8” vertical with screws and glue.
NOTE that the height of the camera determines the size of the document and the focus needed. You may want to go higher for larger area documents.

5. Cut a 1”x1/16” slit in the box top near the 8” vertical for the camera cable to pass thru.

NOTE: For the electronics, I suggest NOT to permanently mount the components yet, so that you can easily make adjustments.

6. Connect the 24” camera cable to the camera. DO NOT CONNECT TO RASPBERRY yet.

Step 3: Hardware Cont...

7. Mount the camera facing downward from the end of the 5” wood strip. I suggest waiting before placing the camera in its case so that you can focus the lens easier once running!

For initial focusing, use the Adjustment tool and turn the lens counter clockwise 1/4! turn.

8. Run the camera cable down thru the slot then attach it to the Pi. (Be sure Pi is OFF!)

9. Install the momentary button and connect wires between it and Pi GPIO pins 24 and GND.
And connect the button’s LED through a 220 ohm resistor to Pi GPIO pins 18 and GND.

10. Run the power supply into the box and plug into the Pi. You need to use strain relief such as hot melt glue or similar to plug the hole in the box so the cable can’t pull out.

Step 4: Audio Hardware Install...

11. For the audio, I used a mono speaker that used USB power and mini jack audio.
I removed the electronics and speaker from the original plastic case, and plugged the audio plug into the Pi audio jack and USB cable into Pi USB. I also replaced the original tiny speaker with a larger 3” one for much better sound quality.

Since I mounted the speaker under the lid of the box, I drilled multiple small holes in the shape of a speaker grill.

12. Finally, check connections, particularly the camera cable and GPIO connections.

DO NOT POWER UP THE PI YET. Continue to software setup first…

There is no On/Off switch, as it is assumed that the Pi should be running all the time so it is ready to read something immediately. It only uses a few watts and can run 24/7 without issues.

It is possible for the SD card to become corrupted if unplugged or power failure, but it is rare. I have never had a unbootable SD card, yet. But do not plug into a power strip that is turned off/on regularly.

Step 5: Operating System Setup & Configuration

Format an 8GB or larger microSD card with Raspbian Jessie (or Stretch) Lite (no GUI for this project).

https://www.raspberrypi.org/downloads/raspbian/

You will need to access the Raspberry remotely via SSH. On Windows, you can use PUTTY SSH terminal program. On Mac, just bring up a command terminal window. Alternately, you can temporarily plug a keyboard and HDMI monitor in just to get it built, but SSH makes it easier to work on later.

---------------------------------------

Did you know?
If you install Raspbian Jessie on an SD card using a Windows PC, you can create two files on the card to configure WiFi and SSH access before you boot it on a Raspberry?

For this, assume your SD card is currently mounted as K: on your PC:

1) Install the latest Raspbian Jessie image to the SD. For this project, Jessie Lite should work. https://www.raspberrypi.org/downloads/raspbian/

2) With notepad, create a file called just “ssh” and use Save As “All files” to K:\ssh The file can contain anything. It’s the filename that is important. Must NOT be “ssh.txt”!!!

3) With notepad, create a file called “wpa_supplicant.conf” with following:

<p>ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev<br>update_config=1</p><p>network={
   ssid="mySSID"
   psk="mypassword"
   key_mgmt=WPA-PSK
}</p>

Use Save As “All files” to K:\wpa_supplicant.conf
Again, do not let Notepad change it to “wpa_supplicant.conf.txt”!!

When you boot the Raspberry the first time, Jessie will look for these and connect to your Wifi. You will have to look on your Router for the IP address, though, since its auto assigned using DHCP.

---------------------------------------

Now ready to install to your Pi:

1. Insert the microSD card into the Pi and plug in the power now.

2. To remotely log in to your Raspberry Pi, you will need to find its IP address. You can try:

$ ssh pi@raspberrypi.local

Or from Putty, enter hostname: pi@raspberrypi.local

Otherwise, you will need to see if your Router will show the IP addresses of your local devices.

Once logged in as pi user:

3. Update your Raspbian OS:

$ sudo apt update

$ sudo apt upgrade

4. Configure the Raspberry and enable the camera:

$ sudo raspi-config

a. Change User Password

b. Interfacing Options -> Camera -> Enable

c. Finish

d. Reboot

Step 6: Application Software Installation

Now log back into your Pi and you are ready to install the PiTextReader application.

1. Install initial required software:
$ sudo apt install git –y

2. Download the software:

$ cd /home/pi

$ git clone https://github.com/rgrokett/PiTextReader.git

$ cd PiTextReader

$ sh install.sh

You can safely rerun the install.sh multiple times, if needed.

3. Place a simple document to be read and run the test program which sets the volume, plays some text-to-speech audio and takes a picture.

$ sh test.sh

If you get any error messages, check Troubleshooting below. Edit the test.sh program to adjust the volume if necessary.

4. The test program saves a photo to “test.jpg”. You will need to copy this image over to a PC so that you can see the focus and the field of view. A quick & dirty way to do this is to start a tiny web server on your Pi and use a browser:

$ python -m SimpleHTTPServer 8080 &

Then browse to http://{IPaddress}:8080/

Click on the test.jpg

Use the Lens adjustment tool to focus the camera.

Re-Run the test.sh program as often as needed.

NOTE: if you need to adjust the raspistill camera settings, you will need to also edit the pitextreader.py program with the new settings.

CAMERA = "raspistill -cfx 128:128 --awb auto -rot 90 -t 500 -o /tmp/image.jpg"

5. $ sudo reboot

The Pi should come up and run automatically, ready for operation.

Step 7: Operation

When you boot the Pi, you will hear a “OK Ready” as well as see the button LED light up.

Anytime the LED is lit, the unit is ready to go.

Put some printed text under the camera, preferably just a few lines of black text on white paper.

Note that the camera doesn’t need a lot of light, particularly the NoIR. Ambient room light was fine for mine. Too much light causes uneven lighting and distorts the OCR.

Press the button.

The LED should light and a camera click sound as well as speech “OK working” should sound.

After a few seconds, the text should be read. If the text is distorted, font too dark or too light, sideways or upside down, then the result will be gobbly-gook speech!

It can take between 5-30 seconds to convert and start reading, so be patient. The more text, the longer it takes.

If you need to stop reading, you can press the button while the audio is still playing (the LED is off.)

Once the speech is completed, after a couple seconds, the LED comes back on and you will hear “OK Ready” again. It’s ready to take another scan.

Note that the distance the camera is set for the Raspi camera and for just a portion of a 8x10 document. I found it is best to read parts of a document at a time as full pages can be hard to listen to. Many of the things needed to be read are smaller text, so if the camera is too far away, it can’t resolve.

To troubleshoot, check below, particularly the SCANNING AND OCR section.

If all is well, permanently mount all the components to complete the construction.

Step 8: Troubleshooting

1. CAMERA

Verify the camera is enabled via

$ sudo raspi-config

Interfacing Options -> Camera

Reseat the ribbon cable as this is delicate and must be exactly aligned. If necessary, google “raspberry pi camera troubleshooting” to look for similar issues. Also google the error message you get when running the test.sh program.

2. AUDIO

You do have volume up?

$ sudo amixer -q sset PCM,0 100%

Run audio test

$ aplay /usr/share/sounds/alsa/Front_Center.wav

No audio still? Force audio out the jack:

$ sudo raspi-config Advanced Options -> Audio -> Force headphone jack

3. SPEECH

If audio above sounds good, then try:

$ flite -t TEST

Google error messages, if any.

Rerun the install.sh

Yes, the speech sounds a bit like Stephen Hawking.

4. SCANNING AND OCR

This is the biggest area of tuning needed. For the OCR to work properly, the camera image must be good quality; the document must be smoothly lit, not necessarily brightly though.

The text must be flat and clear. Not all fonts are readable.

To verify the quality, examine the two files:

/tmp/text.txt and /tmp/image.jpg

You can start the tiny web server and use a browser:

$ cd /tmp $ python -m SimpleHTTPServer 8080 &

The text in the image should be plain and readable. The image should be right side up, good contrast, in focus. You may need to flip the document around if it’s upside down. (remind the user that if they hear gobbly-gook, then try flipping the document around. ) If the image has poor contrast, you will need to improve the lighting, too much or too little can cause problems. Uneven lighting will also cause parts of the text to fail. You can find more help by googling “tesseract-ocr help

5. HDMI MONITOR/KEYBOARD

Yes, you can plug a keyboard & monitor into the Pi, esp. if you can’t find the IP address or can’t access via SSH. There is no GUI interface and this may turn off the sound unless your monitor has a speaker.

6. INTERNET/WIFI

If the WIFI isn’t working, you can just temporarily connect an Ethernet cable and use that.

This project doesn’t need Internet or WiFi once you have completed the installation and setup.

Share

Recommendations

  • Remix Contest

    Remix Contest
  • Warm and Fuzzy Contest

    Warm and Fuzzy Contest
  • Epilog X Contest

    Epilog X Contest

23 Discussions

0
None
RaisB2

5 days ago

if I use a USB camera. What should I do?
please reply

1 reply
0
None
rgrokettRaisB2

Reply 15 hours ago

Not sure if a USB webcam would work as most are too low resolution for optical character recognition (OCR) work. The Pi camera is 8 megapixel capable of 3280 x 2464 resolution.

If your camera is of this high a quality, then to use it, you would probably have to change the default raspistill program for one called fswebcam.
https://www.raspberrypi.org/documentation/usage/we...

You would have to change the line 38 in my pitextreader.py program to use the new program:
CAMERA="raspistill -cfx 128:128 --awb auto -rot 180 -t 500 -o /tmp/image.jpg"

I don't have a usb webcam so don't know the arguments that would be needed using fswebcam, but you can just start by using its defaults, changing it to use the output filename /tmp/image.jpg then looking at this image file to see if the text is clear and easily readable. Blurry text cannot be read by the OCR program.

0
None
Priyanila

7 weeks ago

Some of the command line commands seems to be old.So does this git hub code works fine even now ?is the git hub code updated ?

7 replies
1
None
rgrokettPriyanila

Reply 7 weeks ago

Yes, it should be just fine with Raspbian Stretch Lite. The installation commands and script will install the latest versions of the OCR and text-to-speech programs. Note that this does use python 2.7 (the default) and not python3. Also, should be fine even on the newest and less expensive Raspberry Pi 3 A+.

0
None
Priyanilargrokett

Reply 5 weeks ago

Tq rgrokett.when boot up "ok ready " is heard.My document is not read.I believe the picture taken by the camera is good.still document is not read.Also there is no text in text.txt file....Can u suggest the solution

1
None
rgrokettPriyanila

Reply 5 weeks ago

If you are not getting a /tmp/text.txt file, then the OCR software isn't able to read the text in the image. Can you post a copy of the /tmp/image.jpg file here?

The most likely issues are that the image is out of focus or too bright or too dark.
More details are avail in Step 8. Troubleshooting item 4. Scanning and OCR.

If the image text looks ok, then I suggest turning on DEBUG mode:

$ cd /home/pi/PiTextReader
$ nano pitextreader.py

Edit the line:
##### USER VARIABLES
DEBUG = 1 # Debug 0/1 off/on (writes to debug.log)

Reboot the pi to rerun in debug mode.
You can then check the /home/pi/PiTextReader/debug.log file.
$ cat debug.log
0
None
Priyanilargrokett

Reply 26 days ago

Tq rgrokett.Its working now but with random text .As you said the problem is with image taken by camera.I use NOIR camera.I am working on it to focus it...quite difficult

1
None
rgrokettPriyanila

Reply 20 days ago

Yes, the NOIR camera may not be as sharp if the light source has both Infrared and visible light since they focus at different wavelengths. Incandescent lights have both. Some LED lights might be better than incandescent (or sunlight!) as visible light LEDs don't emit much IR light. (Unless they are IR LEDS!)

0
None
Priyanilargrokett

Reply 19 days ago

Thanks a lot for ur response rgrogett.The project is working fine for me now.How could I add Tamil language in tesseract and tts in program code.

0
None
SitiL

22 days ago

Hi ! can I change the text to speech software using espeak ?

1 reply
0
None
judillajn

6 months ago

Hello, great project. But having trouble making it read text. Have some questions. Can i contact you on your email?

judillajn@gmail.com

1
None
hanshadow

11 months ago

Great Project! I designed a 3D printed case (files and pics attached) and over at MyMiniFactory (3D PRINTED OCR TEXT READER) that is working well, easy to print and has camera positioned for the scan surface.

Adafruit has a little 2.5W mono amp for $4 that works well, gets very loud if you crank up mixer to 100%. I noticed focus is very important, an eight of a turn off can give erratic results.

Lots of fun!

OCR.jpgparts.jpgInside.jpg
0
None
erniman

Question 11 months ago on Step 8

Hi! Thanks for share your proyect...it´s amazing. I´ll try it this weekend. Just a question, there is a way to use it in Spanish? (I know that tesseract software support severals languagues). Thanks again!!!

1 answer
0
None
rgroketterniman

Answer 11 months ago

To support Spanish, I believe you would need to change the Text to Speech engine from Flite to Festival as I don't believe Flite supports Spanish.

I think Tesseract OCR would support Spanish, but you would need to add the language package and also change the tesseract command in the pitextreader.py slightly:

$ sudo apt-get install tesseract-ocr-spa

cmd = "/usr/bin/tesseract -l spa /tmp/image.jpg /tmp/text"

Changing the program to use festival instead of flite is a little more involved, but if you experiment with the command line version of festival and then substitute it for the flite commands in pitextreader.py it should work.

http://www.cstr.ed.ac.uk/projects/festival/

If you have used GitHub, you could fork it and modify your copy for others to use.
https://github.com/rgrokett/PiTextReader

0
None
carlos66ba

11 months ago

Very nice! Thanks for sharing. One question: what is the field of view of the camera? Could it be set to read in the "portrait" mode so that it may capture an entire US Letter or A4 page?

1 reply
1
None
rgrokettcarlos66ba

Reply 11 months ago

By heightening the arm holding the camera, a larger field of view is available. While assembling, just hold the camera at various heights and run the test.sh program to take photos.

BUT, two issues: The OCR takes about 1 second per line of text, so full pages could take a couple minutes to convert before speaking. Also, too small a font can't be resolved by the camera.

"Real" (i.e. expensive) readers use flatbed scanners to scan in and then OCR the document using a more powerful computer (laptop).

Microsoft does offer a free app for iphone (maybe android, too) called SeeingAI which is amazing, but requires relatively tech savy use of smartphone and Internet connection or cellular data. https://www.microsoft.com/en-us/seeing-ai/