bottle-ocr-lib


Namebottle-ocr-lib JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/MichaelCrosson/bottle-ocr-lib
SummaryProfessional OCR and AI-powered prescription extraction library with secure license validation
upload_time2025-10-26 22:55:41
maintainerNone
docs_urlNone
authorMichael Crosson
requires_python>=3.8
licenseMIT
keywords ocr prescription ai image-processing healthcare paddleocr openai
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🏥 BottleOCR Library

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)

Professional OCR and AI-powered prescription extraction library with secure license validation and local processing capabilities.

## ✨ Features

- 🔍 **High-Accuracy OCR** - Advanced PaddleOCR text extraction
- 🤖 **AI-Powered Analysis** - OpenAI GPT-4 prescription data extraction  
- 🔐 **Secure License System** - One-time server validation, then local processing
- 🖼️ **Multi-Format Support** - JPEG, PNG, TIFF, BMP, PDF, numpy arrays, PIL Images
- ⚡ **Batch Processing** - Process multiple images efficiently
- 💾 **Smart Caching** - Offline operation after initial validation
- 🛠️ **Easy Integration** - Simple API with comprehensive documentation
- 📊 **Structured Output** - 18+ prescription fields extracted automatically

## 🚀 Quick Start

### Installation

```bash
pip install bottle-ocr-lib
```

### Basic Usage

```python
from bottle_ocr_lib import BottleOCR

# Initialize with your API key (validates once, then works offline)
ocr = BottleOCR(api_key="your-api-key-here")

# Process prescription bottle images
result = ocr.process_single_image("prescription_bottle.jpg")

# Access extracted prescription data
prescription = result['prescription']
print(f"💊 Medication: {prescription['medication_name']}")
print(f"💉 Dosage: {prescription['dosage']}")
print(f"👤 Patient: {prescription['patient_name']}")
print(f"🏥 Pharmacy: {prescription['pharmacy_name']}")
```

### Batch Processing

```python
# Process multiple images at once
results = ocr.process_images([
    "bottle_front.jpg",
    "bottle_back.jpg", 
    "label_close_up.png"
])

for i, result in enumerate(results['images']):
    if result['status'] == 'success':
        prescription = result['prescription']
        print(f"Image {i+1}: {prescription['medication_name']}")
```

## 🔐 License System

BottleOCR uses a secure validation system enabling **complete local processing**:

1. **Initial Validation**: Your API key validates with our server (one-time only)
2. **Encoded Key Delivery**: Server provides encrypted OpenAI API key
3. **Local Processing**: All subsequent operations run offline on your machine
4. **Smart Caching**: No repeated server communication required

```python
# First run: Server validation + local caching
ocr = BottleOCR(api_key="your-key")  # ✅ Online validation

# All future runs: Instant startup from cache  
ocr = BottleOCR(api_key="your-key")  # ✅ Offline, instant
results = ocr.process_images(images)  # ✅ 100% local processing
```

## 📊 Extracted Prescription Data

The library extracts comprehensive prescription information:

| Field | Description | Example |
|-------|-------------|---------|
| `medication_name` | Drug name | "Amoxicillin" |
| `dosage` | Strength/amount | "500mg" |
| `quantity_dispensed` | Amount given | "30 capsules" |
| `patient_name` | Patient name | "John Doe" |
| `prescriber_name` | Doctor name | "Dr. Smith" |
| `pharmacy_name` | Pharmacy name | "Main St Pharmacy" |
| `prescription_date` | Fill date | "2024-10-25" |
| `expiration_date` | Expiry date | "2025-10-25" |
| `directions_for_use` | Instructions | "Take twice daily" |
| `refills_remaining` | Refills left | "2" |
| `rx_number` | Prescription # | "RX7654321" |
| `ndc_number` | NDC code | "12345-678-90" |
| `lot_number` | Lot number | "ABC123" |
| `manufacturer` | Drug maker | "Generic Co" |
| `warning_labels` | Warnings | "May cause drowsiness" |
| `storage_instructions` | Storage | "Store at room temp" |
| `dosage_form` | Form type | "Capsule" |
| `description_of_pill` | Appearance | "Blue oval tablet" |

## 🖥️ Command Line Interface

```bash
# Process single image
bottle-ocr process image.jpg --api-key your-key

# Process multiple images
bottle-ocr batch *.jpg --output results.json --api-key your-key

# Get account information
bottle-ocr info --api-key your-key

# Validate images without processing
bottle-ocr validate image1.jpg image2.jpg --api-key your-key
```

## ⚙️ Configuration

### Environment Variables
```bash
export BOTTLEOCR_API_KEY="your-api-key"
```

### Custom Configuration
```python
config = {
    "ocr": {
        "language": "en",
        "confidence_threshold": 0.8,
        "use_gpu": True
    },
    "extraction": {
        "model": "gpt-4",
        "temperature": 0.1
    }
}

ocr = BottleOCR(api_key="your-key", config=config)
```

## 📝 Complete Example

```python
from bottle_ocr_lib import BottleOCR
from bottle_ocr_lib.utils.exceptions import AuthenticationError, ValidationError

try:
    # Initialize (validates license once)
    ocr = BottleOCR(api_key="your-api-key")
    
    # Process images (works offline after validation)
    results = ocr.process_images([
        "prescription1.jpg",
        "bottle_label.png"
    ])
    
    # Extract prescription information
    for i, result in enumerate(results['images']):
        if result['status'] == 'success':
            p = result['prescription']
            print(f"""
Image {i+1}:
  Medication: {p['medication_name']}
  Dosage: {p['dosage']}
  Patient: {p['patient_name']}
  Instructions: {p['directions_for_use']}
  Refills: {p['refills_remaining']}
            """)
        else:
            print(f"Image {i+1} failed: {result['error']}")
            
except AuthenticationError as e:
    print(f"❌ License validation failed: {e}")
except ValidationError as e:
    print(f"❌ Invalid input: {e}")
except Exception as e:
    print(f"❌ Unexpected error: {e}")
```

## 🔧 Requirements

- **Python**: 3.8 or higher
- **Platform**: Windows, macOS, Linux
- **Dependencies**: Automatically installed
  - PaddleOCR >= 2.7.0
  - OpenAI >= 1.0.0
  - OpenCV >= 4.5.0
  - Pillow >= 8.0.0
  - PyYAML >= 5.4.0

## 🆘 Getting an API Key

1. **Sign up**: Visit [bottleocr.com](https://bottleocr.com) to create an account
2. **Choose Plan**: Select the subscription that fits your needs
3. **Get Key**: Receive your API key via email after signup
4. **Start Processing**: Use your key to process prescription images immediately

## 📖 Documentation & Support

- 📚 **Examples**: See `examples/` directory for complete usage patterns
- 🐛 **Issues**: [GitHub Issues](https://github.com/yourusername/bottle-ocr-lib/issues)
- 💬 **Support**: support@bottleocr.com
- 📖 **API Docs**: Comprehensive docstrings in all methods

## 📄 License

MIT License - see [LICENSE](LICENSE) file for details.

## 🏆 Why Choose BottleOCR?

- ✅ **Production Ready** - Battle-tested accuracy and reliability
- ✅ **Privacy First** - Your data stays on your machine after validation
- ✅ **Developer Friendly** - Simple API, great documentation, quick setup
- ✅ **Cost Effective** - Pay once, process locally forever
- ✅ **Scalable** - Handle single images or large batch processing
- ✅ **Secure** - Encrypted license validation with local operation

---

**Ready to extract prescription data professionally? [Get your API key today!](https://bottleocr.com)** 🚀

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MichaelCrosson/bottle-ocr-lib",
    "name": "bottle-ocr-lib",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "ocr, prescription, ai, image-processing, healthcare, paddleocr, openai",
    "author": "Michael Crosson",
    "author_email": "Michael Crosson <michael@bottleocr.com>",
    "download_url": "https://files.pythonhosted.org/packages/99/92/17164d3b08cd656c7627c2e4f48d662932aab5513a0d7b640ce2bf9f9285/bottle_ocr_lib-1.0.1.tar.gz",
    "platform": null,
    "description": "# \ud83c\udfe5 BottleOCR Library\r\n\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\r\n\r\nProfessional OCR and AI-powered prescription extraction library with secure license validation and local processing capabilities.\r\n\r\n## \u2728 Features\r\n\r\n- \ud83d\udd0d **High-Accuracy OCR** - Advanced PaddleOCR text extraction\r\n- \ud83e\udd16 **AI-Powered Analysis** - OpenAI GPT-4 prescription data extraction  \r\n- \ud83d\udd10 **Secure License System** - One-time server validation, then local processing\r\n- \ud83d\uddbc\ufe0f **Multi-Format Support** - JPEG, PNG, TIFF, BMP, PDF, numpy arrays, PIL Images\r\n- \u26a1 **Batch Processing** - Process multiple images efficiently\r\n- \ud83d\udcbe **Smart Caching** - Offline operation after initial validation\r\n- \ud83d\udee0\ufe0f **Easy Integration** - Simple API with comprehensive documentation\r\n- \ud83d\udcca **Structured Output** - 18+ prescription fields extracted automatically\r\n\r\n## \ud83d\ude80 Quick Start\r\n\r\n### Installation\r\n\r\n```bash\r\npip install bottle-ocr-lib\r\n```\r\n\r\n### Basic Usage\r\n\r\n```python\r\nfrom bottle_ocr_lib import BottleOCR\r\n\r\n# Initialize with your API key (validates once, then works offline)\r\nocr = BottleOCR(api_key=\"your-api-key-here\")\r\n\r\n# Process prescription bottle images\r\nresult = ocr.process_single_image(\"prescription_bottle.jpg\")\r\n\r\n# Access extracted prescription data\r\nprescription = result['prescription']\r\nprint(f\"\ud83d\udc8a Medication: {prescription['medication_name']}\")\r\nprint(f\"\ud83d\udc89 Dosage: {prescription['dosage']}\")\r\nprint(f\"\ud83d\udc64 Patient: {prescription['patient_name']}\")\r\nprint(f\"\ud83c\udfe5 Pharmacy: {prescription['pharmacy_name']}\")\r\n```\r\n\r\n### Batch Processing\r\n\r\n```python\r\n# Process multiple images at once\r\nresults = ocr.process_images([\r\n    \"bottle_front.jpg\",\r\n    \"bottle_back.jpg\", \r\n    \"label_close_up.png\"\r\n])\r\n\r\nfor i, result in enumerate(results['images']):\r\n    if result['status'] == 'success':\r\n        prescription = result['prescription']\r\n        print(f\"Image {i+1}: {prescription['medication_name']}\")\r\n```\r\n\r\n## \ud83d\udd10 License System\r\n\r\nBottleOCR uses a secure validation system enabling **complete local processing**:\r\n\r\n1. **Initial Validation**: Your API key validates with our server (one-time only)\r\n2. **Encoded Key Delivery**: Server provides encrypted OpenAI API key\r\n3. **Local Processing**: All subsequent operations run offline on your machine\r\n4. **Smart Caching**: No repeated server communication required\r\n\r\n```python\r\n# First run: Server validation + local caching\r\nocr = BottleOCR(api_key=\"your-key\")  # \u2705 Online validation\r\n\r\n# All future runs: Instant startup from cache  \r\nocr = BottleOCR(api_key=\"your-key\")  # \u2705 Offline, instant\r\nresults = ocr.process_images(images)  # \u2705 100% local processing\r\n```\r\n\r\n## \ud83d\udcca Extracted Prescription Data\r\n\r\nThe library extracts comprehensive prescription information:\r\n\r\n| Field | Description | Example |\r\n|-------|-------------|---------|\r\n| `medication_name` | Drug name | \"Amoxicillin\" |\r\n| `dosage` | Strength/amount | \"500mg\" |\r\n| `quantity_dispensed` | Amount given | \"30 capsules\" |\r\n| `patient_name` | Patient name | \"John Doe\" |\r\n| `prescriber_name` | Doctor name | \"Dr. Smith\" |\r\n| `pharmacy_name` | Pharmacy name | \"Main St Pharmacy\" |\r\n| `prescription_date` | Fill date | \"2024-10-25\" |\r\n| `expiration_date` | Expiry date | \"2025-10-25\" |\r\n| `directions_for_use` | Instructions | \"Take twice daily\" |\r\n| `refills_remaining` | Refills left | \"2\" |\r\n| `rx_number` | Prescription # | \"RX7654321\" |\r\n| `ndc_number` | NDC code | \"12345-678-90\" |\r\n| `lot_number` | Lot number | \"ABC123\" |\r\n| `manufacturer` | Drug maker | \"Generic Co\" |\r\n| `warning_labels` | Warnings | \"May cause drowsiness\" |\r\n| `storage_instructions` | Storage | \"Store at room temp\" |\r\n| `dosage_form` | Form type | \"Capsule\" |\r\n| `description_of_pill` | Appearance | \"Blue oval tablet\" |\r\n\r\n## \ud83d\udda5\ufe0f Command Line Interface\r\n\r\n```bash\r\n# Process single image\r\nbottle-ocr process image.jpg --api-key your-key\r\n\r\n# Process multiple images\r\nbottle-ocr batch *.jpg --output results.json --api-key your-key\r\n\r\n# Get account information\r\nbottle-ocr info --api-key your-key\r\n\r\n# Validate images without processing\r\nbottle-ocr validate image1.jpg image2.jpg --api-key your-key\r\n```\r\n\r\n## \u2699\ufe0f Configuration\r\n\r\n### Environment Variables\r\n```bash\r\nexport BOTTLEOCR_API_KEY=\"your-api-key\"\r\n```\r\n\r\n### Custom Configuration\r\n```python\r\nconfig = {\r\n    \"ocr\": {\r\n        \"language\": \"en\",\r\n        \"confidence_threshold\": 0.8,\r\n        \"use_gpu\": True\r\n    },\r\n    \"extraction\": {\r\n        \"model\": \"gpt-4\",\r\n        \"temperature\": 0.1\r\n    }\r\n}\r\n\r\nocr = BottleOCR(api_key=\"your-key\", config=config)\r\n```\r\n\r\n## \ud83d\udcdd Complete Example\r\n\r\n```python\r\nfrom bottle_ocr_lib import BottleOCR\r\nfrom bottle_ocr_lib.utils.exceptions import AuthenticationError, ValidationError\r\n\r\ntry:\r\n    # Initialize (validates license once)\r\n    ocr = BottleOCR(api_key=\"your-api-key\")\r\n    \r\n    # Process images (works offline after validation)\r\n    results = ocr.process_images([\r\n        \"prescription1.jpg\",\r\n        \"bottle_label.png\"\r\n    ])\r\n    \r\n    # Extract prescription information\r\n    for i, result in enumerate(results['images']):\r\n        if result['status'] == 'success':\r\n            p = result['prescription']\r\n            print(f\"\"\"\r\nImage {i+1}:\r\n  Medication: {p['medication_name']}\r\n  Dosage: {p['dosage']}\r\n  Patient: {p['patient_name']}\r\n  Instructions: {p['directions_for_use']}\r\n  Refills: {p['refills_remaining']}\r\n            \"\"\")\r\n        else:\r\n            print(f\"Image {i+1} failed: {result['error']}\")\r\n            \r\nexcept AuthenticationError as e:\r\n    print(f\"\u274c License validation failed: {e}\")\r\nexcept ValidationError as e:\r\n    print(f\"\u274c Invalid input: {e}\")\r\nexcept Exception as e:\r\n    print(f\"\u274c Unexpected error: {e}\")\r\n```\r\n\r\n## \ud83d\udd27 Requirements\r\n\r\n- **Python**: 3.8 or higher\r\n- **Platform**: Windows, macOS, Linux\r\n- **Dependencies**: Automatically installed\r\n  - PaddleOCR >= 2.7.0\r\n  - OpenAI >= 1.0.0\r\n  - OpenCV >= 4.5.0\r\n  - Pillow >= 8.0.0\r\n  - PyYAML >= 5.4.0\r\n\r\n## \ud83c\udd98 Getting an API Key\r\n\r\n1. **Sign up**: Visit [bottleocr.com](https://bottleocr.com) to create an account\r\n2. **Choose Plan**: Select the subscription that fits your needs\r\n3. **Get Key**: Receive your API key via email after signup\r\n4. **Start Processing**: Use your key to process prescription images immediately\r\n\r\n## \ud83d\udcd6 Documentation & Support\r\n\r\n- \ud83d\udcda **Examples**: See `examples/` directory for complete usage patterns\r\n- \ud83d\udc1b **Issues**: [GitHub Issues](https://github.com/yourusername/bottle-ocr-lib/issues)\r\n- \ud83d\udcac **Support**: support@bottleocr.com\r\n- \ud83d\udcd6 **API Docs**: Comprehensive docstrings in all methods\r\n\r\n## \ud83d\udcc4 License\r\n\r\nMIT License - see [LICENSE](LICENSE) file for details.\r\n\r\n## \ud83c\udfc6 Why Choose BottleOCR?\r\n\r\n- \u2705 **Production Ready** - Battle-tested accuracy and reliability\r\n- \u2705 **Privacy First** - Your data stays on your machine after validation\r\n- \u2705 **Developer Friendly** - Simple API, great documentation, quick setup\r\n- \u2705 **Cost Effective** - Pay once, process locally forever\r\n- \u2705 **Scalable** - Handle single images or large batch processing\r\n- \u2705 **Secure** - Encrypted license validation with local operation\r\n\r\n---\r\n\r\n**Ready to extract prescription data professionally? [Get your API key today!](https://bottleocr.com)** \ud83d\ude80\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Professional OCR and AI-powered prescription extraction library with secure license validation",
    "version": "1.0.1",
    "project_urls": {
        "Documentation": "https://github.com/MichaelCrosson/bottle-ocr-lib#readme",
        "Homepage": "https://github.com/MichaelCrosson/bottle-ocr-lib",
        "Issues": "https://github.com/MichaelCrosson/bottle-ocr-lib/issues",
        "Repository": "https://github.com/MichaelCrosson/bottle-ocr-lib"
    },
    "split_keywords": [
        "ocr",
        " prescription",
        " ai",
        " image-processing",
        " healthcare",
        " paddleocr",
        " openai"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3f941e1b58cbfc67f11439ea65d7afa5d79de57ffe539448f8dd21be749a8b89",
                "md5": "05fe11156a45daf6e60e4e11f0dd8f04",
                "sha256": "d4912179078b14e42f11b4670bd53b0d7b66dbd228a5722300156032638eefbc"
            },
            "downloads": -1,
            "filename": "bottle_ocr_lib-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "05fe11156a45daf6e60e4e11f0dd8f04",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 39575,
            "upload_time": "2025-10-26T22:55:39",
            "upload_time_iso_8601": "2025-10-26T22:55:39.940018Z",
            "url": "https://files.pythonhosted.org/packages/3f/94/1e1b58cbfc67f11439ea65d7afa5d79de57ffe539448f8dd21be749a8b89/bottle_ocr_lib-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "999217164d3b08cd656c7627c2e4f48d662932aab5513a0d7b640ce2bf9f9285",
                "md5": "027e625fa71a74c2b51199c1db96b89a",
                "sha256": "1b005b3144f7b9bcad595ffa46ad2e87d49434753b617a96639add1f7f117164"
            },
            "downloads": -1,
            "filename": "bottle_ocr_lib-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "027e625fa71a74c2b51199c1db96b89a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 37777,
            "upload_time": "2025-10-26T22:55:41",
            "upload_time_iso_8601": "2025-10-26T22:55:41.170410Z",
            "url": "https://files.pythonhosted.org/packages/99/92/17164d3b08cd656c7627c2e4f48d662932aab5513a0d7b640ce2bf9f9285/bottle_ocr_lib-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-26 22:55:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MichaelCrosson",
    "github_project": "bottle-ocr-lib",
    "github_not_found": true,
    "lcname": "bottle-ocr-lib"
}
        
Elapsed time: 2.33735s