A Python application that performs real-time text detection in images and video streams using OpenCV and the EAST text detector model.
- ✨ Features
- 🔧 Requirements
- 🚀 Installation
- 💻 Usage
- 🔍 How it Works
- 🤝 Contributing
- 📄 License
- 🙏 Acknowledgments
- Real-time text detection in images
- Real-time text detection in video streams and webcam
- Support for multiple text orientations
- Non-maximum suppression for overlapping detections
- Adjustable confidence threshold
- FPS counter for performance monitoring
- Python 3.6+
- OpenCV (cv2)
- NumPy
- imutils
- Pre-trained EAST text detector model
- Clone this repository:
git clone https://github.com/gifflet/opencv-text-detection.git
cd opencv-text-detection
- Install the required packages:
pip install opencv-python numpy imutils
- Download the EAST text detector model (frozen_east_text_detection.pb)
To detect text in an image:
python text_detection.py --image path/to/image.jpg --east frozen_east_text_detection.pb
Optional arguments:
--min-confidence
: Minimum probability to filter weak detections (default: 0.5)--width
: Resized image width (should be multiple of 32)--height
: Resized image height (should be multiple of 32)
To detect text in video or webcam:
# For webcam
python text_detection_video.py --east frozen_east_text_detection.pb
# For video file
python text_detection_video.py --east frozen_east_text_detection.pb --video path/to/video.mp4
The application uses the EAST (Efficient and Accurate Scene Text) detector, which is a deep learning model designed for text detection. The process involves:
- Image preprocessing and resizing
- Running the EAST detector to get text predictions
- Decoding the predictions to get bounding box coordinates
- Applying non-maximum suppression to eliminate overlapping detections
- Drawing the results on the original image/frame
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Project based on the original work by Adrian Rosebrock from PyImageSearch (https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/)
Made with ❤️ by gifflet