Skip to main content

Professional OCR and AI-powered prescription extraction library with secure license validation

Project description

๐Ÿฅ BottleOCR Library

License: MIT Python 3.8+

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

pip install bottle-ocr-lib

Basic Usage

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

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

# 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

export BOTTLEOCR_API_KEY="your-api-key"

Custom Configuration

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

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 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
  • ๐Ÿ’ฌ Support: support@bottleocr.com
  • ๐Ÿ“– API Docs: Comprehensive docstrings in all methods

๐Ÿ“„ License

MIT License - see 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! ๐Ÿš€

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

bottle_ocr_lib-1.0.2.tar.gz (38.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bottle_ocr_lib-1.0.2-py3-none-any.whl (40.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bottle_ocr_lib-1.0.2.tar.gz
  • Upload date:
  • Size: 38.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for bottle_ocr_lib-1.0.2.tar.gz
Algorithm Hash digest
SHA256 33d1309ebe1500bee120ec189a831f3a0ae2a3caebc00f14d0fb03035664874d
MD5 81a036f408fa23d2b8260872ce85828e
BLAKE2b-256 df2c95296ce6907a672c27a668243fcb52ece1fb3a513cd0a7e3361238b8331a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bottle_ocr_lib-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 40.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for bottle_ocr_lib-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 24c5927238e8eb215747e871e421cb0fb4cf1525326e1afadcd73cc7fc5511be
MD5 7736a4692c9ae58ae1021901ea8a3f7e
BLAKE2b-256 0381e1720a408dbbe0f0e60803e666151df849ba0f8e9603a017d99de005dc2b

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