An open API service indexing awesome lists of open source software.

https://github.com/qengineering/opencv_ocr_dnn

Text recognition with OpenCV and deep learning
https://github.com/qengineering/opencv_ocr_dnn

deep-learning ocr ocr-recognition opencv

Last synced: 5 months ago
JSON representation

Text recognition with OpenCV and deep learning

Awesome Lists containing this project

README

          

# OpenCV_OCR_DNN
![output image]( https://qengineering.eu/github/OpenCV_OCR_1.png )
![output image]( https://qengineering.eu/github/OpenCV_OCR_2.png )
## Recognize text with deep learning on a bare Raspberry Pi 4.

[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)


Paper: https://arxiv.org/pdf/1507.05717.pdf

Special made for a bare Raspberry Pi 4, see [Q-engineering deep learning examples](https://qengineering.eu/deep-learning-examples-on-raspberry-32-64-os.html)

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

## Tip.
:point_right: See also [PaddleOCR-Lite](https://github.com/Qengineering/PaddleOCR-Lite-Document) solution. It is 5 times faster and more accurate.

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

## Dependencies.
To run the application, you have to:
- A raspberry Pi 4 with a 32 or 64-bit operating system. It can be the Raspberry 64-bit OS, or Ubuntu 18.04 / 20.04. [Install 64-bit OS](https://qengineering.eu/install-raspberry-64-os.html)

- OpenCV ***version 4.5.1 or higher*** 64-bit installed. [Install OpenCV 4.5](https://qengineering.eu/install-opencv-4.5-on-raspberry-64-os.html)

- Code::Blocks installed. (```$ sudo apt-get install codeblocks```)

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

## Notes.
The image is resized to 100x32 pixels (line 56 at `main.cpp`) before being processed by OpenCV's deep learning engine.

Obvious, your text must be one line and not too long to be recognized properly.

In contrast to tesseract, deep learning models are less sensitive to font, colour, noise, scale, and skew.

For more models, check the [OpenCV tutorial](https://docs.opencv.org/4.x/d4/d43/tutorial_dnn_text_spotting.html). Most consume considerably more computer power, hence more significant interference times.

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

## Installing the app.
To extract and run the network in Code::Blocks

$ mkdir *MyDir*

$ cd *MyDir*

$ wget https://github.com/Qengineering/OpenCV_OCR_DNN/archive/refs/heads/main.zip

$ unzip -j master.zip

Remove master.zip, LICENSE and README.md as they are no longer needed.

$ rm master.zip

$ rm LICENSE

$ rm README.md


Your *MyDir* folder must now look like this:

*.png

alphabet_36.txt

alphabet_94.txt

OpenCV_OCR.cpb

main.cpp

DenseNet_CTC.onnx

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

## Running the app.
To run the application load the project file OpenCV_OCR.cbp in Code::Blocks.

Next, follow the instructions at [Hands-On](https://qengineering.eu/deep-learning-examples-on-raspberry-32-64-os.html#HandsOn).

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

[![paypal](https://qengineering.eu/images/TipJarSmall4.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CPZTM5BB3FCYL)