Skip to main content

Extended MRZ Passport Reader From Image

Project description

MRZ Passport Reader from Image

This project is an implementation of a Machine-Readable Zone (MRZ) reader from images using segmentation, face detection, and Optical Character Recognition (OCR). It leverages TensorFlow Lite models for segmentation, a Caffe model for face detection, and EasyOCR for text recognition.


Features

  • MRZ Detection: Automatically detects and segments the MRZ region in passport images.
  • Face Detection: Identifies and crops the face from the passport image.
  • OCR with EasyOCR: Extracts text from the segmented MRZ region.
  • Preprocessing: Optional preprocessing steps including skew correction, shadow removal, and background clearing to improve OCR accuracy.

Installation

Prerequisites

  • Python 3.10 or higher
  • Git installed

Install from GitHub

git clone https://github.com/devnbugs/xmrzapp.git
cd xmrzapp
pip install -e .


## Example Usage
```python

import cv2
from xmrz_reader import MRZReader

# Initialize the MRZReader
reader = MRZReader(
    facedetection_protxt="./xmrzapp/weights/face_detector/deploy.prototxt",
    facedetection_caffemodel="./xmrzapp/weights/face_detector/res10_300x300_ssd_iter_140000.caffemodel",
    segmentation_model="./xmrzapp/weights/mrz_detector/mrz_seg.tflite",
    easy_ocr_params={"lang_list": ["en"], "gpu": False}
)

# Load an image
image_path = "path_to_your_image.jpg"

# Perform MRZ reading with optional preprocessing and face detection
text_results, segmented_image, detected_face = reader.predict(
    image_path,
    do_facedetect=True,
    preprocess_config={
        "do_preprocess": False,
        "skewness": False,
        "delete_shadow": False,
        "clear_background": False
    }
)

# Display results
print("Recognized Text:")
for bbox, text, confidence in text_results:
    print(f"Bounding Box: {bbox}")
    print(f"Recognized Text: {text}")
    print(f"Confidence: {confidence:.2f}")
    print("-" * 50)

if detected_face is not None:
    print("Face detected in the image.")

# Show images
cv2.imshow("Segmented Image", segmented_image)
if detected_face is not None:
    cv2.imshow("Detected Face", detected_face)
cv2.waitKey(0)
cv2.destroyAllWindows()

Example Result





After you give this image to the models , you will take this result P<GBRUNITED<KINGDOM<FIVE<<JODIE<PIPPA<<<<<<<1071857032GBR8501178F1601312<<<<<<<<<<<<<<02 as a string. This study is a basic solution . Your image which you give should be clear, and it should cover whole area.



Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xmrzapp-25.10.1.tar.gz (16.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xmrzapp-25.10.1-py3-none-any.whl (14.9 MB view details)

Uploaded Python 3

File details

Details for the file xmrzapp-25.10.1.tar.gz.

File metadata

  • Download URL: xmrzapp-25.10.1.tar.gz
  • Upload date:
  • Size: 16.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for xmrzapp-25.10.1.tar.gz
Algorithm Hash digest
SHA256 1ca111f7c8c5230b289bb910cdf6648c3aa94fbf383e5645214dcd7f6aeaa26f
MD5 396ae9ec27e552fb0df3c36465010586
BLAKE2b-256 06f7b68c9161a87bf2866f8cd3ced09cd1947b900c1b0a693904d39a12f33746

See more details on using hashes here.

File details

Details for the file xmrzapp-25.10.1-py3-none-any.whl.

File metadata

  • Download URL: xmrzapp-25.10.1-py3-none-any.whl
  • Upload date:
  • Size: 14.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for xmrzapp-25.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d74475ba2d2d79666a940c6ee7626a6c0b3d1ea9ad017a5ad5ba0e9f76d1937
MD5 d2b59eb49a3cc47d8b0f313e8ce11d6e
BLAKE2b-256 2777a857ef975c00e766fee164d4bf20cb473fb51e84f6236ae584f1c22219c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page