shehzad
Posts: 2
Joined: Tue May 22, 2018 8:10 am

Recommended Camera for OCR based application for blind

Tue May 22, 2018 8:51 am

Hi

I have started to develop an ocr application to read text of book for blinds with raspberry pi through pi camra, I am using Python-tesseract for ocr and pi camera v1.3 for capture image..

The problem is When i capture an image of book's page with pi camera, it did not capture image understand by tesseract,,

I need to help regarding recommendation of any settings of pi camera, lens, web cams etc to capture book page perfectly understand by Python-tesseract..

HermannSW
Posts: 829
Joined: Fri Jul 22, 2016 9:09 pm

Re: Recommended Camera for OCR based application for blind

Tue May 22, 2018 11:47 am

shehzad wrote:
Tue May 22, 2018 8:51 am
, I am using Python-tesseract for ocr and pi camera v1.3 for capture image..
Nice, I was not aware of tesseract.
All that was needed was "sudo apt-get install tesseract-ocr" (for English language).
The problem is When i capture an image of book's page with pi camera, it did not capture image understand by tesseract,,
I did only use "tesseract" command line version and not python-tesseract.
I downloaded the sample image from documentation:
https://github.com/tesseract-ocr/tesser ... r-an-image

Then I did OCR processing:

Code: Select all

[email protected]:~ $ tesseract  --tessdata-dir /usr/share/tesseract-ocr/ eurotext.png eurotext-eng -l eng
Tesseract Open Source OCR Engine v3.04.01 with Leptonica
[email protected]:~ $ 

Next I converted the image to jpeg and did OCR processing again, no difference:

Code: Select all

[email protected]:~ $ pngtopnm eurotext.png | pnmtojpeg > eurotext.jpg
[email protected]:~ $ tesseract  --tessdata-dir /usr/share/tesseract-ocr/ eurotext.jpg eurotext-eng.2 -l eng
Tesseract Open Source OCR Engine v3.04.01 with Leptonica
[email protected]:~ $ diff eurotext-eng.txt eurotext-eng.2.txt 
[email protected]:~ $ 

And jpeg is the default output format of raspistill. So just do this to capture a page and then convert:

Code: Select all

raspistill -o test.jpg
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland
https://github.com/Hermann-SW/wireless-control-Eachine-E52-drone      https://twitter.com/HermannSW

shehzad
Posts: 2
Joined: Tue May 22, 2018 8:10 am

Re: Recommended Camera for OCR based application for blind

Tue May 22, 2018 12:28 pm

Thanks Hermann for kind reply..

my problem when i capture image from picam it did not capture proper image suitable for tessarct.. I am using picam v 1.3..
can you please guide camera, lens or any other tools who capture image properly..

Thanks

HermannSW
Posts: 829
Joined: Fri Jul 22, 2016 9:09 pm

Re: Recommended Camera for OCR based application for blind

Tue May 22, 2018 9:35 pm

Hi,

I have added M12 lens mounts to two of my cameras, and had two NoIR cameras that came with M12 mount and lens.
Now I used a normal v1 camera (NoIR) and just placed it a bit above the page, rotated by 90° to have the bigger camera width (2592 > 1944) cover the page height:
Image


As I said before I took the photo with "raspistill -o test.jpg".
Then I rotated the image with netpbm tools:

Code: Select all

$ jpegtopnm test.jpg | pnmflip -rotate90 | pnmtojpeg > bof.p9.jpg
This was the result:
Image


Then I used tesseract as before, but only few words got correctly decoded.

Next I processed the image with gimp's Threshold Color tool (117):
Image


Here the tesseract output is much better:

Code: Select all

[email protected]:~ $ cat bof.p9.txt 
   

 

    

i

—2.4 -20 —I.O —I2 -03 Ago—on

Fig.2. 7719 Mandelbrot setfor them rux3+c mm
with the window —2.4 < Rec< 08. -l.2<lmc<12 Thom
among the various types 0/ boundaries at Mum! values alt}! .

     
 
   
  
 
  
  

Mandelbrot's process Is mathematically equivalent to thaw.
X... i =/(x )a-x‘. +c

is the simple foqula GIven a number m take its squareandaddm
to get X); then repeat to get x; X}. and so on. Everyone can “mm
one expected to find so much enigmatic beauty hidden In this W "‘1?"-

Let us begin with the simplest possible Choice of the constant 6. VIII 9-“
Then we just square the number at each Iteration: on-oJfiI-ufibl‘» . .
There are three possibilities for the sequence. depending on m: "l ’

i , T he numbers become smaller and smaller their sequence approach.
zeio We say that zero is an attractor for the process XI-oxz. All palatal“
than a distance of i from this attractor are drawn into it.

2. The, numbers become larger and larger tending towards infinity. We any
that infinity Is also an attractor for this process All points farther than a dish I
tance of 1 from zero are drawn into it.

3. The points are at a distance of 1 from zero and stay there. Their sequence
lies on the boundary between the two domains of attraction, in this case the

unit circle around zero.

The situation is clear Two zones of influence divide up the plane, and the

boundary between them is simply a circle \
The surprise comes when we pick 0 to be non-zero, say c=-0.1237‘5
.has the choice Ween

+ 0.56508i. Here. too the sequence x0» x1 I» )9» . _
the three possibilities listed above, but the inner attractor (dot In Fig.3) is no

[email protected]:~ $ 

Far away from good, you will have to read tesseract documentation on how to take images for best OCR processing (light, direction of light, post processing, ...).
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland
https://github.com/Hermann-SW/wireless-control-Eachine-E52-drone      https://twitter.com/HermannSW

Return to “Camera board”