Skip to main content

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

Project description

Khmer NID Detector

Alt text

A Python package for detecting and extracting information from Khmer National ID cards using OCR and computer vision.

Features

  • 🔍 Card Type Detection: Automatically detects various types of cards and documents
  • 🇰🇭 Khmer NID Optimized: Specifically designed for Cambodian National ID cards
  • 📄 Information Extraction: Extracts NID number, name, and date of birth
  • 🖼️ Image Preprocessing: Enhances image quality for better OCR accuracy
  • 🚀 Easy to Use: Simple API with clear documentation

Supported Card Types

  • 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 document

Installation

pip install khmer-nid-detector

example to use

    # from khmer_nid_detector import detect_card_type, process_nid_card

    from khmer_nid_detector import detect_card_type, process_nid_card

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

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

    # If it's an NID card, process it
    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']}")
        else:
            print(f"Error: {result['message']}")

example Structure Code

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

Example to run Code

python3 v1.py   

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: khmer_nid_detector-0.1.2.tar.gz
  • Upload date:
  • Size: 5.5 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.2.tar.gz
Algorithm Hash digest
SHA256 d5683f53f9773de980baf8aca2ee1d6b9c8c4f60ed4e1fba251f461e26986a66
MD5 37e681fd8ed46cea592d8bfcbc2f3a5b
BLAKE2b-256 e938ecd699448cf83a67fafb50926e886da54e0ada613f1e27dc26f58444d160

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for khmer_nid_detector-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 66c6053e1a7bed11e2d8f6b4fc2b7abe5fa85715e3f2ef9c7aadf0d992103c97
MD5 574caa6e24856d2ecd5354616b6ba5c4
BLAKE2b-256 b8cc6f45b4a65a1f75c751c4095ecfd4e3d6e7c28469186f74ab01ea3e5ad975

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