Skip to main content

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

Project description

Khmer NID Detector v1.0.1 🇰🇭

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
└── v1_0_1.py

▶️ Run Example Code

python3 v1_0_1.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-1.0.1.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-1.0.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: khmer_nid_detector-1.0.1.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-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b3cb803a1a4f8787c19db02de8dfcea4a89e6c6e7efa24b84cce575729b05f52
MD5 64bc2102c24b2b43b7c8023c126e72e0
BLAKE2b-256 0cd1c696f069e141c30ce97a339bf6cc913c5df060ec223fd546fb9ad77ae921

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for khmer_nid_detector-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 47a97e28429ca52e3fb7f979eab49fb794b15f58aa10bab4b79099e19a72616c
MD5 f75a8f54a5badfae132acc6a5dc5dfc3
BLAKE2b-256 79cfe546c799c4b3f17a5d2c34857da1ae9a84b2fcf935fc990138b5a0f5567e

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