Overview
CoroNet uses OpenAI’s GPT-4o-mini vision model as the primary OCR engine for license plate extraction. This provides superior accuracy compared to traditional OCR methods, especially for images with varying angles, lighting conditions, or partial obstructions.The OpenAI vision model is implemented in
app.py:44-80 and uses base64 encoding to send images to the API for text extraction.Why OpenAI GPT-4o-mini?
The application uses GPT-4o-mini for several advantages:- High accuracy: Advanced vision capabilities understand context and handle distortions
- Robust recognition: Works with challenging lighting, angles, and image quality
- Natural language processing: Can extract license plates from complex scenes
- Fast processing: Mini variant balances speed and accuracy
- Cost-effective: Lower pricing than full GPT-4o model
Getting Your API Key
Create an OpenAI account
Visit OpenAI Platform and sign up for an account:
- Go to https://platform.openai.com/signup
- Sign up with email or Google/Microsoft account
- Verify your email address
- Complete account setup
Add billing information
- Navigate to Billing
- Click “Add payment method”
- Enter your credit card information
- Set up billing limits (recommended: start with $10-20)
Generate API key
- Go to API Keys
- Click “Create new secret key”
- Give your key a name (e.g., “CoroNet Development”)
- Important: Copy the key immediately - you won’t be able to see it again
- Store the key securely
Model Configuration
CoroNet uses the gpt-4o-mini model for vision tasks. This model is specified inapp.py:50:
app.py
Model Options
You can modify the model based on your needs:To change the model, edit
app.py:50 and replace "gpt-4o-mini" with your preferred model.How the Vision API Works
The implementation in CoroNet follows this workflow:Customizing the Prompt
The current prompt is in Spanish and instructs the model to extract only the license plate text:English Prompt Alternative
You can modify the prompt to English:app.py
Enhanced Prompt for Better Accuracy
For improved results, try this enhanced prompt:API Usage and Costs
Pricing (as of 2026)
GPT-4o-mini pricing:- Input: $0.150 per 1M tokens
- Output: $0.600 per 1M tokens
Vision requests with images cost more due to image tokens. A typical license plate image (1024x768) uses approximately 765 tokens.
Cost Estimation
For a typical license plate extraction:- Image tokens: ~765 tokens
- Prompt tokens: ~50 tokens
- Response tokens: ~10 tokens
- Total per request: ~825 tokens
- Cost per request: ~$0.001 (less than a penny)
- 100 scans/month: ~$0.10
- 1,000 scans/month: ~$1.00
- 10,000 scans/month: ~$10.00
Setting Usage Limits
Protect your account from unexpected charges:Set hard limits
- Go to Billing Settings
- Set “Hard limit” (e.g., $20/month)
- Set “Soft limit” for notifications (e.g., $15/month)
Enable email notifications
Receive alerts when approaching limits:
- 75% of soft limit reached
- 90% of soft limit reached
- Hard limit reached (API access disabled)
Monitor usage
Check your usage regularly:
- Usage Dashboard
- View daily/monthly breakdowns
- Track costs by model
Error Handling
The implementation includes error handling inapp.py:78-80:
Authentication Error
.env file:
Rate Limit Error
Insufficient Quota
Testing the Configuration
Verify your OpenAI setup with this test script:Best Practices
Security
- Never commit API keys to git
- Rotate keys periodically
- Use separate keys for dev/prod
- Monitor usage for anomalies
Cost Optimization
- Set hard billing limits
- Use gpt-4o-mini (not gpt-4o)
- Implement request caching
- Monitor API usage regularly
Error Handling
- Catch API exceptions
- Implement retry logic
- Use Tesseract fallback
- Log errors for debugging
Performance
- Compress images before upload
- Use async requests if possible
- Cache common results
- Implement request queuing
Advanced Configuration
Image Preprocessing
Improve accuracy by preprocessing images before sending to the API:Batch Processing
Process multiple images efficiently:Next Steps
Environment Variables
Complete guide to all configuration options
Tesseract Setup
Install fallback OCR engine
