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.2.tar.gz (7.0 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.2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: khmer_nid_detector-1.0.2.tar.gz
  • Upload date:
  • Size: 7.0 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.2.tar.gz
Algorithm Hash digest
SHA256 73adacdf9caf2f894c203b7bb2665c2275dc03d95fdb33ae0edd30be4720224f
MD5 f2e8f472df2c077bf0685ea858a2559b
BLAKE2b-256 cd858f139f9189810a10a21ba54481014354ff02ac5b10e624275ca7171e327b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for khmer_nid_detector-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dbc4c4620cdc1058b42f22b70d4d0cab2e7838e2da0682cc8e6439cc9b4944dc
MD5 95756f382f8412cc1b6940a416fe4b93
BLAKE2b-256 ef12114efbc54c0eee8d334085e111a1c48eca28485d2aa79cf72b83e4991825

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