Metadata-Version: 2.4
Name: xmrzapp
Version: 25.10.9
Summary: Extended MRZ Passport Reader From Image
Home-page: https://github.com/devnbugs/xmrzapp
Author: rhsalisu
Project-URL: Bug Tracker, https://github.com/devnbugs/xmrzapp/issues
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: opencv_python_headless>=4.5.3.56
Requires-Dist: scipy>=1.5.2
Requires-Dist: imutils>=0.5.4
Requires-Dist: deskew>=0.10.36
Requires-Dist: easyocr>=1.7.1
Requires-Dist: tensorflow>=2.9.0
Provides-Extra: cpu
Requires-Dist: tensorflow-cpu>=2.9.0; extra == "cpu"
Provides-Extra: gpu
Requires-Dist: tensorflow>=2.9.0; extra == "gpu"
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# 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

```bash
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 
 
 
<img align="left" width="33%" src="https://github.com/devnbugs/xmrzapp/blob/main/examples/example.jpg">

<br/><br/>

<img align="left" width="33%" src="https://github.com/devnbugs/xmrzapp/blob/02ae870f473c60fb5fb7f0544e5820aee38987a0/examples/example.jpg">

<br/><br/>

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.
<br/><br/>
<br/><br/>


