A full-stack mobile OCR (Optical Character Recognition) application with image translation and text overlay, built with React Native (Expo) and Flask (Python).
- 📸 Camera Integration: Capture photos using your phone's camera
- 📤 Image Upload: Upload images from gallery for processing
- 🔍 OCR Processing: Extract text from images using EasyOCR
- 🌐 Translation: Translate detected text with visual overlay on images
- ✨ Beautiful UI: Modern interface with loading states and error handling
- 🚀 Fast Processing: Optimized image processing pipeline
realtime-ocr/
├── mobile-app/ # React Native (Expo) frontend
│ ├── app/
│ │ └── (tabs)/
│ │ ├── index.tsx # Home tab
│ │ ├── upload.tsx # Upload & Translation tab
│ │ └── explore.tsx # Profile tab
│ ├── package.json
│ └── README.md
│
└── backend/ # Flask OCR API
├── app.py # Main Flask server
├── requirements.txt # Python dependencies
├── start.sh # Quick start script
└── README.md # Backend documentation
Before running the application, you MUST complete these steps:
- Install all requirements (both backend and frontend)
- Find your computer's IP address
- Update IP addresses in frontend files
- Ensure same port is used (default: 5003)
cd backend
# Install dependencies
pip install -r requirements.txt
# Quick start (recommended)
chmod +x start.sh
./start.sh
# OR manual start:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python app.pyServer will run on: http://0.0.0.0:5003
macOS/Linux:
ipconfig getifaddr en0 # Usually en0 for Wi-Fi
# or
ifconfig | grep "inet " | grep -v 127.0.0.1Windows:
ipconfig
# Look for IPv4 Address under your active network adapterExample output: 10.195.91.229
File: mobile-app/app/(tabs)/upload.tsx
// ⚠️ REPLACE WITH YOUR MAC'S IP ADDRESS
const SERVER_IP = "http://YOUR_IP:5003/api/ocr";Replace YOUR_IP with your actual IP address (e.g., 10.195.91.229)
Note: The index.tsx file is a blank home tab and doesn't require IP configuration.
cd mobile-app
# Install dependencies
npm install
# Start Expo development server
npx expo start- Open Expo Go app on your phone
- Scan the QR code from terminal
- Grant camera and media library permissions
- Test the connection and start using the app!
Default port: 5003
- Backend runs on port 5003 by default
- Frontend MUST use the same port (5003)
- If you change the backend port, update it in all frontend files
Requirements:
- ✅ Both devices (computer and phone) must be on the same Wi-Fi network
- ✅ IP address must be correctly set in frontend files
- ✅ Port must match between frontend and backend (5003)
- ✅ Firewall must allow connections on port 5003
- React Native 0.81.5
- Expo ~54.0.25
- Expo Router ~6.0.15 - File-based routing
- Expo Camera ~17.0.9 - Camera integration
- Expo Image Picker - Image gallery access
- Axios ^1.13.2 - HTTP requests
- TypeScript ~5.9.2 - Type safety
- Flask - Python web framework
- EasyOCR - OCR engine with multi-language support
- OpenCV - Image preprocessing and enhancement
- Pillow - Image processing library
- Flask-CORS - Cross-origin support
┌─────────────┐
│ Mobile App │
│ (Expo) │
└──────┬──────┘
│ 1. Capture/Upload Image
▼
┌─────────────┐
│ Base64 │
│ Encoding │
└──────┬──────┘
│ 2. Send to Backend
▼
┌─────────────┐
│ Flask API │
│ /api/ocr │
└──────┬──────┘
│ 3. OCR + Translation
│ + Overlay Generation
▼
┌─────────────┐
│ Result + │
│ Annotated │
│ Image │
└──────┬──────┘
│ 4. Display
▼
┌─────────────┐
│ Mobile App │
│ (Result) │
└─────────────┘
Test endpoint to verify connectivity.
Response:
{
"status": "ok",
"message": "Connection successful",
"ip": "client_ip",
"server_ip": "10.195.91.229",
"port": 5003,
"easyocr_ready": true
}Perform OCR and optionally translate text with overlay.
Request:
{
"image": "base64_encoded_image_string",
"target_lang": "ZH", // Optional: Language code for translation
"return_overlay": true, // Optional: Return annotated image
"include_segment_data": false // Optional: Include coordinates
}Response:
{
"text": "Extracted text",
"translated_text": "Translated text",
"annotated_image": "data:image/png;base64,...",
"confidence": 0.95
}Cannot start server:
# Make sure dependencies are installed
cd backend
pip install -r requirements.txt
# Check if port is available
lsof -ti:5003 | xargs kill -9 # Kill process on port 5003Module not found:
# Activate virtual environment
source venv/bin/activate
pip install -r requirements.txtCannot connect to backend:
- ✅ Backend server is running
- ✅ Both devices on same Wi-Fi network
- ✅ IP address is correct in
upload.tsx - ✅ Port matches: Frontend uses same port as backend (5003)
- ✅ Firewall allows port 5003
Test connection:
curl http://YOUR_IP:5003/api/testModule not found:
cd mobile-app
rm -rf node_modules package-lock.json
npm installConnection timeout:
- Verify both devices are on the same network
- Check firewall settings
- Try pinging your computer's IP from the phone
- Ensure backend is listening on
0.0.0.0:5003(not just127.0.0.1)
Before uploading to GitHub:
Root .gitignore:
# Backend
backend/venv/
backend/__pycache__/
backend/*.pyc
backend/*.log
backend/.env
backend/annotated_results/
backend/dataimages/
# Frontend
mobile-app/node_modules/
mobile-app/.expo/
mobile-app/.expo-shared/
mobile-app/dist/
mobile-app/*.log
mobile-app/.DS_Store
# General
.DS_Store
*.log
.env
# Initialize git (if not already done)
git init
# Add all files
git add .
# Commit
git commit -m "Add real-time OCR app with translation overlay"
# Add remote (replace with your repository URL)
git remote add origin https://github.com/yourusername/realtime-ocr.git
# Push to GitHub
git push -u origin main- Check that all files are uploaded
- Verify
.gitignoreis working (nonode_modulesorvenvfolders) - Test cloning the repository to ensure it works
Before uploading to GitHub:
- All requirements installed (
pip install -r requirements.txtandnpm install) - IP addresses updated in frontend files
- Port configuration matches (5003)
-
.gitignorefile created/updated - No sensitive data (API keys, passwords) in code
- README files updated with instructions
- Code tested and working
- All files committed
- ✅ Install all requirements (backend and frontend)
- ✅ Find your IP address
- ✅ Update IP addresses in frontend files
- ✅ Ensure same port (5003) is used
- ✅ Start backend server
- ✅ Start frontend app
- ✅ Test connection
- ✅ Upload to GitHub
- Image Upload: ~1-3 seconds (depending on network)
- OCR Processing: ~2-5 seconds (first request may take longer)
- Translation: ~1-2 seconds
- Overlay Generation: ~1-2 seconds
- Total Time: ~5-12 seconds per image
For production deployment:
- Use HTTPS instead of HTTP
- Add API authentication (JWT tokens)
- Implement rate limiting
- Add input validation
- Use environment variables for configuration
- Deploy backend to cloud service
- Use production WSGI server (Gunicorn)
MIT License - Free to use for personal and commercial projects!
Feel free to submit issues and enhancement requests!
-
Install Requirements:
- Backend:
cd backend && pip install -r requirements.txt - Frontend:
cd mobile-app && npm install
- Backend:
-
Update IP Address:
- Find your IP:
ipconfig getifaddr en0 - Update
mobile-app/app/(tabs)/upload.tsx
- Find your IP:
-
Use Same Port:
- Backend default: 5003
- Frontend must use: 5003
-
Upload to GitHub:
- Create
.gitignore - Commit and push all files
- Create
Happy coding! 🎉