Text Detection
π Overview
Use OpenCV's built-in EAST text detector to box the text regions in a frame in real time. EAST is an efficient deep-learning text detection model integrated directly into OpenCV's DNN module, so there is nothing to train yourself.
Once the text boxes are found you can hand them to OCR (Tesseract or PaddleOCR, for example) to extract the content, giving you the full 'locate first, recognise second' pipeline used as a front end for document and licence plate recognition.
π§° What you need
- Computer + camera (or an image containing text)
- Python 3.7+ environment
- pip install: opencv-python, numpy
- The EAST model weights (frozen_east_text_detection.pb)
π§ Step by step
Prepare the model
Download the EAST model from OpenCV or GitHub
The model is a .pb file that OpenCV's DNN module loads directly
Load the network
Load the model with cv2.dnn.readNet
The output layers are fixed at two layers such as 'feature_fusion/Conv_7/Sigmoid'
Pre-process the input
Scale the image proportionally to the model input size (320x320, for example)
Record the scale factor and map the detections back to the original coordinates
Forward pass
Build the input with blobFromImage and run net.forward
The output holds a confidence and box geometry for every point
Decode the boxes
Decode the box coordinates and confidences from the output
Merge overlapping boxes with non-maximum suppression
Draw and hook up OCR
Draw the text boxes on the original image
Optional: crop the regions and feed them to OCR for the content
π‘ Tips
- EAST works well on horizontal text; vertical or decorative type needs extra handling
- A confidence threshold around 0.5 is typical; raise it to 0.6 if you would rather miss text than mislabel it
- Larger inputs are more accurate but slower - 640 may be too heavy for real-time use