Skip to content

This is an OCR program designed for travel document. It can now support 23 types of documents with pre-defined template. You can add whatever you like.

License

Notifications You must be signed in to change notification settings

wisebobo/doc_ocr_by_template

Repository files navigation

Document OCR by template

This is an OCR program designed for travel document. It can now support 23 types of documents with pre-defined template. You can add whatever you like.

  1. Passport
  2. China ID card
  3. HK ID card (new format)
  4. HK ID card (old format)
  5. Macau ID card (new format)
  6. Macau ID card (old format)
  7. Macau ID card - backside with MRZ
  8. China to HK/Macau Entry Permit card
  9. China to HK/Macau Entry Permit (Old)
  10. China to Taiwan Entry Permit card
  11. HK/Macau to China Entry Permit card
  12. HK/Macau to China Entry Permit card (Old)
  13. Taiwan to China Entry Permit card
  14. Taiwan to China Entry Permit (Old)
  15. Australia Driver Licence - New South Wales
  16. Australia Driver Licence - Victoria
  17. Australia Driver Licence - Capital Territory
  18. Australia Driver Licence - Queensland
  19. Australia Driver Licence - Western
  20. Australia Driver Licence - Northern Territory
  21. Australia Driver Licence - Tasmania
  22. Australia Driver Licence - South Australia
  23. New Zealand Driver Licence

Environment

  • CentOS / Windows
  • python 3.7+

Installation

git clone --recursive https://github.com/wisebobo/doc_ocr_by_template
cd doc_ocr_by_template
pip3 install -r requirements.txt

How to use?

Go to project folder, edit the settings.py to update those APP_ID/APP_KEY to your own one.

Then execute

./startServer.sh

or

python3 startServer.py

Image text

Design Concept

  1. Running tornado for exposing API service
  2. After receiving base64 image, pass to a pre-trained ResNet50 model for image classification to retrieve the document type.
  3. After getting the document type, create multiple threads to call Tencent/Baidu/Face++/Netease/JD OCR API to retrieve the 1st round of OCR result
  4. Base on the 1st round of OCR result, to match against the pre-defined template. Template is created by using the [project folder]/templates/template_generator.html. If template match, crop the recognition area to a new image (idea is to remove those unnecessary information to get a more accurate OCR result), then pass to Tencent/Baidu/Face++/Netease/JD OCR API again.
  5. Match the 2nd OCR result against the template fields
  6. According to corresponding document type to apply respective data cleasing logic
  7. Calculate the score

Reference

  1. MRZ https://github.com/konstantint/PassportEye

About

This is an OCR program designed for travel document. It can now support 23 types of documents with pre-defined template. You can add whatever you like.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published