Professional OCR and AI-powered prescription extraction library with secure license validation
Project description
๐ฅ BottleOCR Library
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:
- Initial Validation: Your API key validates with our server (one-time only)
- Encoded Key Delivery: Server provides encrypted OpenAI API key
- Local Processing: All subsequent operations run offline on your machine
- 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
- Sign up: Visit bottleocr.com to create an account
- Choose Plan: Select the subscription that fits your needs
- Get Key: Receive your API key via email after signup
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bottle_ocr_lib-1.0.0.tar.gz.
File metadata
- Download URL: bottle_ocr_lib-1.0.0.tar.gz
- Upload date:
- Size: 37.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b61e86259597c6df866f570ecdca6d8b6dcd2c7285c1789e3aab49752ad607e
|
|
| MD5 |
c34ee6c9dfe65db6122b6375155c162b
|
|
| BLAKE2b-256 |
6dd95554d7d3e4a71931d360294fbb65c09172e7c8c3b12a687422ba39679d59
|
File details
Details for the file bottle_ocr_lib-1.0.0-py3-none-any.whl.
File metadata
- Download URL: bottle_ocr_lib-1.0.0-py3-none-any.whl
- Upload date:
- Size: 39.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbd22997dbb6db49cfee199337b6aea62b8b4f9178d06f91186d31433498fcd4
|
|
| MD5 |
e0f5599993356775288ace1bd2ae5e00
|
|
| BLAKE2b-256 |
88a7d364daf3b25c7682a215ce9ff9675005692bedd563a4c8178be8c3314c94
|