The OCR Prescription Reader is a hybrid system that combines advanced image processing, Tesseract OCR for text extraction, and AI-powered validation to enhance accuracy. This project automates the process of extracting, validating, and structuring prescription data, reducing errors and improving healthcare workflows.
- Image Preprocessing:
- Noise reduction, adaptive thresholding, and morphological operations for improved OCR accuracy.
 
- Text Extraction:
- Utilizes Tesseract OCR to extract text from prescription images.
 
- AI Integration:
- Validates and refines extracted text using the Gemini AI Model, ensuring consistency and accuracy.
 
- Drug Interaction Check:
- RxNorm
 
- PDF Output:
- Steps:
- Convert image to grayscale for simplicity.
- Apply denoising using Non-Local Means filtering.
- Perform adaptive thresholding to binarize the image.
- Invert the binary image and apply dilation for contour detection.
 
- Purpose: Enhances text clarity and prepares the image for OCR.
- Uses Tesseract OCR to detect and extract text regions from preprocessed images.
- Bounding boxes are generated for potential text areas, which are cropped, resized, and analyzed.
- Extracted text is passed to the Gemini AI Model for validation and correction.
- Gemini Enhancements:
- Corrects abbreviations and errors in medication names.
- Standardizes dosage units and frequencies (e.g., "QD" → "once daily").
- Structures the data into a clear and consistent format.
 
- Results are saved as:
- A JSON file for programmatic use.
- A PDF report for easy sharing and documentation.
 
- Image Input:
- Upload a prescription image via the web interface.
 
- Processing:
- Preprocess the image and extract text using Tesseract OCR.
 
- Validation:
- AI validates and structures the extracted text.
 
- Output:
- View structured text and download the PDF report.
 
- Handwritten Text:
- Tesseract OCR struggles with highly variable handwriting.
- Designed primarily for printed prescriptions.
 
- Image Quality:
- Poor-quality or low-resolution images may impact accuracy.
 
- Enhanced Models:
- Replace Tesseract with advanced deep learning-based OCR models like CRNN or Vision Transformers for better handwriting recognition.
 
- Edge Deployment:
- Optimize for mobile and IoT devices for on-the-go prescription analysis.
 
- Multilingual Support:
- Extend support to non-English prescriptions and international drug standards.
 
- Environment:
- Python 3.8+
- Tesseract OCR installed locally.
 
- Dependencies:
- numpy,- opencv-python,- pytesseract,- requests,- fpdf,- dotenv, and- google.generativeai.
 
| Name | GitHub | |
|---|---|---|
| Abdulmonem Elsherif | @AbdulmonemElsherif | |
| Sharif Ehab | @Sharif_Ehab | 








