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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xmrzapp-25.10.9.tar.gz.
File metadata
- Download URL: xmrzapp-25.10.9.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c805f34c6850e4e9f6f753537f9fda9bb8560591bceca35798817f5a9b3432a
|
|
| MD5 |
f115590a16f2e4bbeef4dfe99c6683dd
|
|
| BLAKE2b-256 |
ada6c2c612e06e1feb3aa71a6390293396a1c77fedc6b182a678bb36a9336dbb
|
File details
Details for the file xmrzapp-25.10.9-py3-none-any.whl.
File metadata
- Download URL: xmrzapp-25.10.9-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3520ee3b6591ffb0ec73ec5e94de36b5911fbf73117cc82bfe7523b6d806764c
|
|
| MD5 |
62281b4296593b5423e67b7cc9cc58fa
|
|
| BLAKE2b-256 |
1e349c0860b395b30960c8282e5a8e44240d389abaabdfb53adc9a641ec20e97
|