Skip to main content

A Python library for detecting and extracting data from Cambodian National ID cards.

Project description

Khmer NID Detector v0.1.5 🇰🇭

Khmer NID Detector

Unlock the power of AI for Cambodian document automation!
Khmer NID Detector is a cutting-edge Python package that leverages advanced OCR and Computer Vision to detect and extract key information from Khmer National ID cards. Streamline your workflow and boost accuracy for Cambodian ID recognition.


🌐 PyPI Project Page

Discover more and get the latest updates on PyPI


Find Docs Support

Khmer-NID-Detector-Docs

📦 Quick Installation

Install instantly from PyPI:

pip install khmer-nid-detector

🚀 Features

  • 🔍 Smart Card Type Detection – Instantly identifies card or document type.
  • 🇰🇭 Khmer NID Focused – Optimized for Cambodian National ID cards.
  • 📄 Rich Information Extraction – Extracts NID number, name, and date of birth.
  • 🖼️ Image Preprocessing – Enhances image clarity for superior OCR results.
  • ⚡ Lightweight & User-Friendly – Minimal dependencies, simple API.
  • 🧠 Intelligent Parsing – Combines regex, heuristics, and OCR for robust data extraction.

🪪 Supported Card Types

Type Description
nid_card Khmer National ID card
credit_card Credit card
debit_card Debit card
driver_license Driver’s license
business_card Business card
other_document Other document types
not_a_card Not a card or unsupported doc

💡 Example Usage

from khmer_nid_detector import detect_card_type, process_nid_card

with open("nid_card.jpg", "rb") as f:
    image_bytes = f.read()

card_type = detect_card_type(image_bytes)
print(f"Detected card type: {card_type}")

if card_type == "nid_card":
    result = process_nid_card(image_bytes)

    if result.success:
        print(f"NID Number: {result.nid_number}")
        print(f"Name: {result.name}")
        print(f"Date of Birth: {result.dob}")
        print(f"Is Khmer NID: {result.is_khmer_nid}")
        print(f"Message: {result.message}")
        print(f"Suggestion: {result.suggestion}")
    else:
        print(f"Error: {result.message}")

📁 Example Project Structure

.
├── IMG_20251005_154748.png
├── nid_card.jpg
├── nid_env
│   ├── bin
│   ├── include
│   ├── lib
│   ├── pyvenv.cfg
│   └── share
└── v5.py

▶️ Run Example Code

python3 v5.py

⚙️ Requirements

  • Python 3.8+
  • easyocr
  • opencv-python
  • Pillow
  • pytesseract
  • numpy

Install dependencies manually if needed:

pip install -r requirements.txt

🧠 How It Works

  1. Preprocessing: Cleans and enhances the input image.
  2. Card Type Detection: Classifies the image into supported types.
  3. Text Extraction (OCR): Extracts Khmer and English text using EasyOCR and Tesseract.
  4. Information Parsing: Detects NID number, name, and date of birth.

🧑‍💻 Author

Roem Reaksmey
AI Developer / Computer Vision Researcher
📧 roemreaksmey7@gmail.com


📄 License

Licensed under the MIT License – see the LICENSE file for details.


❤️ Acknowledgments

  • OpenCV, EasyOCR & Tesseract OCR for image processing
  • Khmer OCR research community
  • Contributors supporting Khmer AI development

✨ Example Output

Detected card type: nid_card
NID Number: 012345678
Name: Sok Dara
Date of Birth: 1998-03-25
Is Khmer NID: True
Message: Khmer NID detected successfully

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

khmer_nid_detector-0.1.5.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

khmer_nid_detector-0.1.5-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file khmer_nid_detector-0.1.5.tar.gz.

File metadata

  • Download URL: khmer_nid_detector-0.1.5.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for khmer_nid_detector-0.1.5.tar.gz
Algorithm Hash digest
SHA256 e5cbb81391be16b6373f076b4573b964f159e64551784f37c80177265714c71d
MD5 8ffd5d091aea7a8b374197eb76c363e5
BLAKE2b-256 285ad434b4e8a4554c20311fa23f33b2a79e667b75e4421ec0e745cb9e95fc4f

See more details on using hashes here.

File details

Details for the file khmer_nid_detector-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for khmer_nid_detector-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a49f1d687c7902ca3351c072f468fccb8672a5e484c8c8780457e02346cd21ef
MD5 de5e548e74e78e084771f75c0c5e778f
BLAKE2b-256 421780a126a6938657425c113cfaedd832c773f0d44cf32cba10930413aef99b

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