Metadata-Version: 2.1
Name: khmer-nid-detector
Version: 0.1.3
Summary: A Python library for detecting and extracting data from Cambodian National ID cards.
Home-page: https://github.com/Smey09/khmer_nid_detector
Author: Roem Reaksmey
Author-email: roemreaksmey7@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: opencv-python
Requires-Dist: pytesseract
Requires-Dist: Pillow
Requires-Dist: easyocr

# Khmer NID Detector

![Alt text](example.png)

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

```bash
pip install khmer-nid-detector
```

### example to use

```python
    # 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   
```
