Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Navigation
Click here to download the source code to this post
In this tutorial you will learn how to use OpenCV to detect text in natural scene images using the EAST text detector.
OpenCV’s EAST text detector is a deep learning model, based on a novel architecture and training pattern. It is capable
Free
of (1) running at near real-time at 13 FPS on 720p images and (2) obtains 17-day
state-of-the-art textcrash
detection accuracy. ×
In the remainder of this tutorial you will learn how to use OpenCV’s EASTcourse
detector to on Computer
automatically detect text in both
images and video streams.
Vision, OpenCV, and
Deep Learning
To discover how to apply text detection with OpenCV, just keep reading!
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 1/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
In this tutorial, you will learn how to use OpenCV to detect text in images using the EAST text detector.
The EAST text detector requires that we are running OpenCV 3.4.2 or OpenCV 4 on our systems — if you do not already
have OpenCV 3.4.2 or better installed, please refer to my OpenCV install guides and follow the one for your respective
operating system.
In the first part of today’s tutorial, I’ll discuss why detecting text in natural scene images can be so challenging.
From there I’ll briefly discuss the EAST text detector, why we use it, and what makes the algorithm so novel — I’ll also
include links to the original paper so you can read up on the details if you are so inclined.
Finally, I’ll provide my Python + OpenCV text detection implementation so you can start applying text detection in your
own applications.
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 2/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Due to the proliferation of cheap digital cameras, and not to mention the fact that nearly every smartphone now has a
camera, we need to be highly concerned with the conditions the image was captured under — and furthermore, what
assumptions we can and cannot make. I’ve included a summarized version of the natural scene text detection challenges
described by Celine Mancas-Thillou and Bernard Gosselin in their excellent 2017 paper, Natural Scene Text
Understanding below:
Image/sensor noise: Sensor noise from a handheld camera is typically higher than that of a traditional scanner.
Additionally, low-priced cameras will typically interpolate the pixels of raw sensors to produce real colors.
Viewing angles: Natural scene text can naturally have viewing angles that are not parallel to the text, making the
text harder to recognize.
Blurring: Uncontrolled environments tend to have blur, especially if the end user is utilizing a smartphone that does
not have some form of stabilization.
Lighting conditions: We cannot make any assumptions regarding our lighting conditions in natural scene images. It
may be near dark, the flash on the camera may be on, or the sun may be shining brightly, saturating the entire image.
Resolution: Not all cameras are created equal — we may be dealing with cameras with sub-par resolution.
Non-paper objects: Most, but not all, paper is not reflective (at least in context of paper you are trying to scan). Text
in natural scenes may be reflective, including logos, signs, etc.
Non-planar objects: Consider what happens when you wrap text around a bottle — the text on the surface becomes
distorted and deformed. While humans may still be able to easily “detect” and read the text, our algorithms will
struggle. We need to be able to handle such use cases.
Unknown layout: We cannot use any a priori information to give our algorithms “clues” as to where the text resides.
As we’ll learn, OpenCV’s text detector implementation of EAST is quite robust, capable of localizing text even when it’s
blurred, reflective, or partially obscured:
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 3/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
With the release of OpenCV 3.4.2 and OpenCV 4, we can now use a deep learning-based text detector called EAST,
which is based on Zhou et al.’s 2017 paper, EAST: An Efficient and Accurate Scene Text Detector.
We call the algorithm “EAST” because it’s an: Efficient and Accurate Scene Text detection pipeline.
The EAST pipeline is capable of predicting words and lines of text at arbitrary orientations on 720p images, and
furthermore, can run at 13 FPS, according to the authors.
Perhaps most importantly, since the deep learning model is end-to-end, it is possible to sidestep computationally
expensive sub-algorithms that other text detectors typically apply, including candidate aggregation and word partitioning.
To build and train such a deep learning model, the EAST method utilizes novel, carefully designed loss functions.
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 4/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Notice that I’ve provided three sample pictures in the images/ directory. You may wish to add your own images collected
with your smartphone or ones you find online.
Both scripts make use of the serialized EAST model ( frozen_east_text_detection.pb ) provided for your convenience in
the “Downloads”.
Implementation notes
The text detection implementation I am including today is based on OpenCV’s official C++ example; however, I must
admit that I had a bit of trouble when converting it to Python.
To start, there are no Point2f and RotatedRect functions in Python, and because of this, I could not 100% mimic the
C++ implementation. The C++ implementation can produce rotated bounding boxes, but unfortunately the one I am
sharing with you today cannot.
Secondly, the NMSBoxes function does not return any values for the Python bindings (at least for my OpenCV 4 pre-
release install), ultimately resulting in OpenCV throwing an error. The NMSBoxes function may work in OpenCV 3.4.2 but I
wasn’t able to exhaustively test it.
I got around this issue my using my own non-maxima suppression implementation in imutils, but again, I don’t believe
these two are 100% interchangeable as it appears NMSBoxes accepts additional parameters.
Given all that, I’ve tried my best to provide you with the best OpenCV text detection implementation I could, using the
working functions and resources I had. If you have any improvements to the method please do feel free to share them in
the comments below.
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 5/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
15 help="minimum probability required to inspect a region")
16 ap.add_argument("-w", "--width", type=int, default=320,
17 help="resized image width (should be multiple of 32)")
18 ap.add_argument("-e", "--height", type=int, default=320,
19 help="resized image height (should be multiple of 32)")
20 args = vars(ap.parse_args())
To begin, we import our required packages and modules on Lines 2-6. Notably we import NumPy, OpenCV, and my
implementation of non_max_suppression from imutils.object_detection .
Important: The EAST text requires that your input image dimensions be multiples of 32, so if you choose to adjust your -
-width and --height values, make sure they are multiples of 32!
From there, Lines 30 and 31 determine the ratio of the original image dimensions to new image dimensions (based on
Free 17-day crash ×
the command line argument provided for --width and --height ).
Free 17-day crash course on Computer
course on Computer
Vision, OpenCV, and Deep Learning
Then we resize the image, ignoring aspect ratio (Line 34).
Vision, OpenCV, and
Deep
In order to perform text detection using OpenCV and the EAST deep learning Learning
model, we need to extract the output
feature maps of two layers:
Interested in computer vision, OpenCV, and
OpenCV Text Detection (EAST text detector) Python
deep learning, but don't know where to
37 # define the two output layer names for the EAST detector model that
start?
38 # we are interested -- the first is the output probabilities and the Let me help. I've created a free, 17-day
39 # second can be used to derive the bounding box coordinates of crash
text course that is hand-tailored to give you
40 layerNames = [
41 "feature_fusion/Conv_7/Sigmoid", the best possible introduction to computer
42 "feature_fusion/concat_3"] vision and deep learning. Sound good? Enter
your email below to get started.
We construct a list of layerNames on Lines 40-42:
1. The first layer is our output sigmoid activation which gives us the probability of a region containing text or not.
Email Address
2. The second layer is the output feature map that represents the “geometry” of the image — we’ll be able to use this ✕
👋Hey there! Which of these best describes
geometry to derive the bounding box coordinates of the text in the input image
START
you?
MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 6/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
We load the neural network into memory using cv2.dnn.readNet by passing the path to the EAST detector (contained in
our command line args dictionary) as a parameter on Line 46.
Then we prepare our image by converting it to a blob on Lines 50 and 51. To read more about this step, refer to Deep
learning: How OpenCV’s blobFromImage works.
To predict text we can simply set the blob as input and call net.forward (Lines 53 and 54). These lines are
surrounded by grabbing timestamps so that we can print the elapsed time on Line 58.
By supplying layerNames as a parameter to net.forward , we are instructing OpenCV to return the two feature maps
that we are interested in:
The output geometry map used to derive the bounding box coordinates of text in our input images
And similarly, the scores map, containing the probability of a given region containing text
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 7/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Lines 72-77 extract our scores and geometry data for the current row, y .
Next, we loop over each of the column indexes for our currently selected row:
For every row, we begin looping over the columns on Line 80.
We need to filter out weak text detections by ignoring areas that do not have sufficiently high probability (Lines 82 and
83).
The EAST text detector naturally reduces volume size as the image passes through the network — our volume size is
actually 4x smaller than our input image so we multiply by four to bring the coordinates back into respect of our original
Free 17-day crash ×
image.
Free 17-day crash course on Computer
course on Computer
Vision, OpenCV, and Deep Learning
I’ve included how you can extract the angle data on Lines 91-93; however, as I mentioned in the previous section, I
Vision, OpenCV, and
wasn’t able to construct a rotated bounding box from it as is performed in the C++ implementation — if you feel like
Deep Learning
tackling the task, starting with the angle on Line 91 would be your first step.
Interested
From there, Lines 97-105 derive the bounding box coordinates for the text area. in computer vision, OpenCV, and
deep learning, but don't know where to
We then update our rects and confidences lists, respectively (Lines start?
109 andLet110).
me help. I've created a free, 17-day
crash course that is hand-tailored to give you
We’re almost finished! the best possible introduction to computer
vision and deep learning. Sound good? Enter
The final step is to apply non-maxima suppression to our bounding boxes to suppress weak overlapping bounding boxes
your email below to get started.
and then display the resulting text predictions:
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 8/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
116 # loop over the bounding boxes
117 for (startX, startY, endX, endY) in boxes:
118 # scale the bounding box coordinates based on the respective
119 # ratios
120 startX = int(startX * rW)
121 startY = int(startY * rH)
122 endX = int(endX * rW)
123 endY = int(endY * rH)
124
125 # draw the bounding box on the image
126 cv2.rectangle(orig, (startX, startY), (endX, endY), (0, 255, 0), 2)
127
128 # show the output image
129 cv2.imshow("Text Detection", orig)
130 cv2.waitKey(0)
As I mentioned in the previous section, I could not use the non-maxima suppression in my OpenCV 4 install (
cv2.dnn.NMSBoxes ) as the Python bindings did not return a value, ultimately causing OpenCV to error out. I wasn’t fully
able to test in OpenCV 3.4.2 so it may work in v3.4.2.
Instead, I have used my non-maxima suppression implementation available in the imutils package (Line 114). The
results still look good; however, I wasn’t able to compare my output to the NMSBoxes function to see if they were
identical.
Lines 117-126 loop over our bounding boxes , scale the coordinates back to the original image dimensions, and draw
the output to our orig image. The orig image is displayed until a key is pressed (Lines 129 and 130).
As a final implementation note I would like to mention that our two nested for loops used to loop over the scores and
geometry volumes on Lines 68-110 would be an excellent example of where you could leverage Cython to dramatically
speed up your pipeline. I’ve demonstrated the power of Cython in Fast, optimized ‘for’ pixel loops with OpenCV and
Python.
Start by grabbing the “Downloads” for this blog post and unzip the files.
From there, you may execute the following command in your terminal (taking note of the two command line arguments):
OpenCV Text Detection (EAST text detector) Free 17-day crash ×Shell
1 $ python text_detection.py --image images/lebron_james.jpg \ Free 17-day crash course on Computer
2 --east frozen_east_text_detection.pb course on Computer
Vision, OpenCV, and Deep Learning
3 [INFO] loading EAST text detector...
4 [INFO] text detection took 0.142082 seconds Vision, OpenCV, and
Your results should look similar to the following image: Deep Learning
Interested in computer vision, OpenCV, and
deep learning, but don't know where to
start? Let me help. I've created a free, 17-day
crash course that is hand-tailored to give you
the best possible introduction to computer
vision and deep learning. Sound good? Enter
your email below to get started.
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 9/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Figure 4: Famous basketball player, Lebron James’ jersey text is successfully recognized with OpenCV and EAST
text detection.
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 10/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Figure 5: Text is easily recognized with Python and OpenCV using EAST in this natural scene of a car wash
station.
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 11/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Figure 6: Scene text detection with Python + OpenCV and the EAST text detector successfully detects the text on
this Spanish stop sign.
This scene contains a Spanish stop sign. The word, “ALTO” is correctly detected by OpenCV and EAST.
As you can tell, EAST is quite accurate and relatively fast taking approximately 0.14 seconds on average per image.
We begin by importing our packages. We’ll be using VideoStream to access a webcam and FPS to benchmark our
Email Address
frames per second for this script. Everything else is the same as in the previous section.
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 12/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
For convenience, let’s define a new function to decode our predictions function — it will be reused for each frame and
make our loop cleaner:
This dedicated function will make the code easier to read and manage later on in this script.
Email Address
✕
👋Hey there! Which of these best describes you?
Let’s parse our command line arguments:
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 13/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
O68 #CVconstruct
T D thei argument
(EAST parser
d and parse
) the arguments P h
69 ap = argparse.ArgumentParser()
70 ap.add_argument("-east", "--east", type=str, required=True,
71 help="path to input EAST text detector")
72 ap.add_argument("-v", "--video", type=str,
73 help="path to optinal input video file")
74 ap.add_argument("-c", "--min-confidence", type=float, default=0.5,
75 help="minimum probability required to inspect a region")
76 ap.add_argument("-w", "--width", type=int, default=320,
77 help="resized image width (should be multiple of 32)")
78 ap.add_argument("-e", "--height", type=int, default=320,
79 help="resized image height (should be multiple of 32)")
80 args = vars(ap.parse_args())
The primary change from the image-only script in the previous section (in terms of command line arguments) is that I’ve
substituted the --image argument with --video .
Important: The EAST text requires that your input image dimensions be multiples of 32, so if you choose to adjust your -
-width and --height values, ensure they are multiples of 32!
Next, we’ll perform important initializations which mimic the previous script:
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 14/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
110 fps = FPS().start()
From there we initialize our frames per second counter on Line 110 and begin looping over incoming frames:
Our frame is resized, maintaining aspect ratio (Line 124). From there, we grab dimensions and compute the scaling ratios
(Lines 129-132). We then resize the frame again (must be a multiple of 32), this time ignoring aspect ratio since we have
stored the ratios for safe keeping (Line 135).
Inference and drawing text region bounding boxes take place on the following lines:
Detect text regions using EAST via creating a blob and passing it through the network (Lines 139-142)
Decode the predictions and apply NMS (Lines 146 and 147). We use the decode_predictions function defined
previously in this script and my imutils non_max_suppression convenience function.
Loop over bounding boxes and draw them on the frame (Lines 150-159). This involves scaling the boxes by the
ratios gathered earlier.
From there we’ll close out the frame processing loop as well as the script itself:
We update our fps counter each iteration of the loop (Line 162) so that timings can be calculated and displayed (Lines
173-175) when we break out of the loop.
We show the output of EAST text detection on Line 165 and handle keypresses (Lines 166-170). If “q” is pressed for
“quit”, we break out of the loop and proceed to clean up and release pointers.
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 16/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
This result is not quite as fast as the authors reported (13 FPS); however, we are using Python instead of C++. By
optimizing our for loops with Cython, we should be able to increase the speed of our text detection pipeline.
Summary
In today’s blog post, we learned how to use OpenCV’s new EAST text detector to automatically detect the presence of
text in natural scene images.
The text detector is not only accurate, but it’s capable of running in near real-time at approximately 13 FPS on 720p
images.
In order to provide an implementation of OpenCV’s EAST text detector, I needed to convert OpenCV’s C++ example;
however, there were a number of challenges I encountered, such as:
If you would like to download the code and images used in this post, please enter your email address in the form below.
Email Address
Not only will you get a .zip of the code, I’ll also send you a FREE 17-page Resource Guide on Computer Vision,
OpenCV, and Deep Learning.👋 ✕
Heyyou'll
Inside there!find Which of these
my hand-picked best describes
tutorials, you?and libraries to help you
books, courses,
START MY EMAIL COURSE
master CV and DL! Sound good? If so, enter your email address and I’ll send you the code immediately!
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 17/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Email address:
Enter your email address below to get my free 17-page Computer Vision, OpenCV,
and Deep Learning Resource Guide PDF. Inside you'll find my hand-picked tutorials,
books, courses, and Python libraries to help you master computer vision and deep
learning!
east text detector, ocr, optical character recognition, text, text detection
Email Address
✕
👋25,
Pavlin B August Hey
2018there!
at 2:30 pmWhich
# of these best describes you?
START MY EMAIL COURSE
REPLY
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 18/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Regards.
REPLY
Adrian Rosebrock August 30, 2018 at 9:34 am #
REPLY
Bartosz December 11, 2018 at 9:34 am #
REPLY
renka June 7, 2019 at 6:27 am #
hi iam also intersted doing research in text detection can yo please send that code to me that works for
both lnguages
REPLY
Jacky December 8, 2018 at 5:08 am #
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 19/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Correction: the EAST paper is from 2017, not 2007. I was really surprised to see a 2007 paper to have a RPN-like
CNN structure. 😉
REPLY
Adrian Rosebrock August 20, 2018 at 2:39 pm #
That was indeed a typo on my part, thank you for pointing it out! I’ve corrected the post.
REPLY
FUXIN YU August 20, 2018 at 12:35 pm #
Hi Author,
Thanks for your posting, this is really good material to learn ML and CV.
one question, how to get the text content which has been recognized in the box?
Thanks,
Fred
REPLY
Adrian Rosebrock August 20, 2018 at 2:36 pm #
Once you have the ROI of the text area you could pass it into an algorithm that that is dedicated to performing
Optical Character Recognition (OCR). I’ll be posting a separate guide that demonstrates how to combine the text
detection with the text recognition phase, but for the time being you should refer to this guide on Tesseract OCR.
REPLY
Markus Dieterle August 21, 2018 at 8:30 am #
Hello Adrian,
Great post! As far as the text extraction goes I think we should take into concideration what was already written in
the “Natural Scene Text Understanding” paper. Free 17-day crash ×
Basically, even if the text areas are properly located, you should doFree
some imagecrash
17-day processing taking
course into account
on Computer
course
variations in lighting, color, hue, saturation, light reflection etc. Once the extracted
Vision,
on
OpenCV,
Computer
pieces of the Learning
and Deep image have been
cleaned up, OCR should work more reliably. Vision, OpenCV, and
Though I’m not sure if an additional, well trained neural network would not even be better – that would offer more
options for retraining for different charcter sets and languages…
Deep Learning
Interested in computer vision, OpenCV, and
deep learning, but don't know where to
start? Let me help. I've created a free, 17-day
REPLY
Gaurav A August 22, 2018 at 4:19 am #
crash course that is hand-tailored to give you
Hi Adrian, the best possible introduction to computer
vision and deep learning. Sound good? Enter
First of all thanks a lot for posting this brilliant article.It helps a lot.
your email below to get started.
Also when can we expect to get article on how to combine text detection with text recognition.
Need it a bit urgently 🙁
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 20/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
REPLY
Adrian Rosebrock August 22, 2018 at 9:21 am #
I’m honestly not sure, Gaurav. I have some other posts I’m working on and then I’ll be swinging back to
text recognition. Likely not for another few weeks/months.
Thanks for the update Adrian. But can you guide me some path may be some links/post to refer on
how to do text recognition after text detection. It would be really helpful.
REPLY
Joan August 23, 2018 at 6:12 am #
Hi Adrian,
If you will be making a guide for OCR this dataset may interest you:
http://artelab.dista.uninsubria.it/downloads/datasets/automatic_meter_reading/gas_meter_reading/gas_meter_reading.html
It contains images of gas counters with all the annotations (coordinates of boxes and digits). I trained a model with
that dataset and it performed really well even with different fonts. If you happen to know a similar dataset please tell
me, thanks and great post!
REPLY
Adrian Rosebrock August 23, 2018 at 6:49 am #
Wow, this is a really, really cool dataset — thank you for sharing, Joan! What type of model did you
train on the data? I see they have annotations for both segmentation of the meter followed by the detection of
the digits.
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 21/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
I’m not an Anaconda user but you should be able to pip install it once you’ve created an environment:
Additionally, this thread on GitHub documents users who had trouble installing imutils for one reason or another. Be
sure to give it a read.
REPLY
wh August 20, 2018 at 4:30 pm #
REPLY
Adrian Rosebrock August 21, 2018 at 6:44 am #
The authors reported 13 FPS on a standard laptop/desktop. The benchmark was not on the Pi.
REPLY
farshad August 20, 2018 at 11:48 pm #
Great work again Adrian. thanks a lot. I recently noticed that Opencv in version 3.4.2 support one of the best and
most accurate tensorflow models: Faster rcnn inception v2 in object detection. In some recent posts of your blog you used
caffe model in opencv. Could on please make a post on implementation of faster rcnn inception v2 on Opencv?
REPLY
Adrian Rosebrock August 21, 2018 at 1:45 pm #
Thank you for the suggestion Farshad, I will try to do a post on Faster R-CNNs.
REPLY
kaisar khatak September 24, 2018 at 1:46 pm #
Cool post. Does this method also work on vertical text??? Free 17-day crash ×
Free 17-day crash course on Computer
course on Computer
Vision, OpenCV, and Deep Learning
Vision, OpenCV, and REPLY
Joppu August 21, 2018 at 12:51 am #
Deep Learning
Nice! Couldn’t have read this at a better time. Thanks alot! Also nice guitar man \m/
Interested in computer vision, OpenCV, and
I’ve been recently searching for a good scene text detection/recognition implementation for a little project of mine. Thinking
deep learning, but don't know where to
of somehow using TextBoxes++ (https://arxiv.org/abs/1801.02765) but now can try out EAST.
start? Let me help. I've created a free, 17-day
crash course that is hand-tailored to give you
the best possible introduction to computer
Adrian Rosebrock August 21, 2018 at 6:46 am # vision and deep learning. Sound good? Enter
REPLY
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 22/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Checking for the solution online, the function is not available in python using this reference.
https://github.com/opencv/opencv/issues/11226
REPLY
Adrian Rosebrock August 21, 2018 at 6:47 am #
Hey Ronrick — I’m not sure why that may happening. Try building OpenCV 4 and see if that resolves the issue.
Here is an OpenCV 4 + Ubuntu install tutorial and here is an OpenCV 4 + macOS install tutorial. I hope that resolve the
issue for you!
REPLY
Gaxo June 27, 2019 at 8:36 am #
Remove that slash while running the file from cmd i.e.
REPLY
Deepayan August 21, 2018 at 4:05 am #
Great post-Adrian. I myself was trying to tweak f-RCNN for text detection on Sanskrit document images, but the
results were far from satisfactory. I’ll try this out. Thanks a lot 🙂
REPLY
Adrian Rosebrock August 21, 2018 at 6:48 am #
Yes. To quote the post: vision and deep learning. Sound good? Enter
your email below to get started.
“To start, there are no Point2f and RotatedRect functions in Python, and because of this, I could not 100% mimic the
C++ implementation. The C++ implementation can produce rotated bounding boxes, but unfortunately the one I am
Email Address
sharing with you today cannot.”
✕
And secondly: 👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 23/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
“I’ve included how you can extract the angle data on Lines 91-93; however, as I mentioned in the previous section, I
wasn’t able to construct a rotated bounding box from it as is performed in the C++ implementation — if you feel like
tackling the task, starting with the angle on Line 91 would be your first step.”
The conclusion also mentions this behavior as well. Please feel free to work with the code, I’ve love to have a rotated
bounding box version as well!
REPLY
Big Adam August 21, 2018 at 5:44 am #
Hi, Adrian
Thanks for the sharing,the script works well.Could you please explain more about the lines in function decode_predictions
especially the computation of bounding box?
REPLY
Danny August 21, 2018 at 10:45 am #
Hi Adrian,
Thank you for this sharing. In addition, could you please let me know whether we can use this EAST text detector to
recognize other languages like Spanish, Korea, Mandarin and so on?
REPLY
Adrian Rosebrock August 21, 2018 at 1:45 pm #
Hey Danny, you should see my reply to Adam, the very first commenter on the post. I haven’t tried with non-
English words but a PyImageSearch reader was able to detect Tamil text so I imagine it will work for other texts as well.
You should download some images with Spanish, Korean, Mandarin, etc. and give it a try!
REPLY
Tom August 21, 2018 at 3:01 pm #
Hi Adrian
Free 17-day crash ×
I noticed that the bounding box on rotated text wasn’t quite enclosing all of Free 17-day
the text. I’ve crash course
calculated on Computer
a more accurate
course
Vision,
bounding box by replacing lines 102-109 in text_detection.py with the following OpenCV,
on Computer
and Deep Learning
Vision, OpenCV, and Python
1 # A more accurate bounding box for rotated text Deep Learning
2 offsetX = offsetX + cos * xData1[x] + sin * xData2[x]
3 offsetY = offsetY - sin * xData1[x] + cos * xData2[x]
4 Interested in computer vision, OpenCV, and
5 # calculate the UL and LR corners of the bounding rectangle deep learning, but don't know where to
6 p1x = -cos * w + offsetX
7 p1y = -cos * h + offsetY start? Let me help. I've created a free, 17-day
8 p3x = -sin * h + offsetX crash course that is hand-tailored to give you
9 p3y = sin * w + offsetY
10 the best possible introduction to computer
11 # add the bounding box coordinates vision and deep learning. Sound good? Enter
12 rects.append((p1x, p1y, p3x, p3y))
your email below to get started.
tom
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE REPLY
Adrian Rosebrock August 22, 2018 at 9:26 amClick
# to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 24/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Thank you for sharing, Tom! I’m going to test this out as well and if it works, likely update the blog post 🙂
REPLY
Tobi October 18, 2018 at 3:14 am #
Hi Tom,
thanks for sharing your code. I compared it to Adrians version and need to state that your coordinates in fact are a bit
more precise (at least for my use case –> text detection from scanned pdf).
Therefore, thanks a ton.
Best regards,
Tobi
REPLY
Hakan Gultekin August 22, 2018 at 3:37 am #
Hi Adrian,
But I have one issue. Your prediction (inference) time is 0.141675 seconds. When I run it, I get 0.413854 seconds.
I am using a Pascal GPU (p2.xlarge) on AWS cloud. Do need to configure something else for faster predictions. What are
you using for running your code ?
Thanks again.
Hakan
REPLY
Adrian Rosebrock August 22, 2018 at 9:21 am #
I was using my iMac to run the code. You should not need any other additional optimizations provided you
followed one of my OpenCV install tutorials to install OpenCV.
You can find the pre-trained model in the “Downloads” section of the blog
Email post. Use the “Downloads” section to
Address
download the code along with the text detection model.
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 25/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
REPLY
Antonio August 22, 2018 at 9:02 am #
Great article Adrian, incredible! Thanks a lot for your valuable tutorials! I am really looking forward to read the
article about the text extraction from ROIs.
REPLY
Adrian Rosebrock August 22, 2018 at 9:17 am #
Thanks Antonio! I’m so happy you enjoyed the guide. I’m looking forward to writing the text recognition tutorial
but it will likely be a few more weeks.
REPLY
mohamed August 23, 2018 at 5:59 am #
Hi Adrian
Wonderful progress as usual
But I have a question please
I want to build the model frozen_east_text_detection.pb myself. Are there some guidelines?
thank you for your effort
REPLY
Adrian Rosebrock August 23, 2018 at 6:09 am #
For training instructions, you’ll want to refer to the official EAST model repo that was published by the authors
of the paper.
REPLY
mohamed August 23, 2018 at 6:29 am #
REPLY
Darshil K August 23, 2018 at 8:09 am # Email Address
✕
Hi, 👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 26/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Thanks!
REPLY
Adrian Rosebrock August 24, 2018 at 8:41 am #
To be honest, I’m not a Windows user and I do not support Windows here on the PyImageSearch blog. I have
OpenCV install tutorials for macOS, Ubuntu, and Raspbian, so if you can use one of those, please do. Otherwise, if
you’re a Windows user, you’ll want to refer to the OpenCV documentation.
REPLY
Deiner Zapata September 20, 2018 at 1:33 pm #
Hi, I am using windows7 too, and execute this code without trouble. Adrian Rosebrock, thanks by your code,
this tutorial is awesome.
More details:
– Python 3.6.5
– Opencv 3.4.2
– Windows 10
REPLY
Adrian Rosebrock October 8, 2018 at 1:14 pm #
Thanks Deiner 🙂
REPLY
Trami August 24, 2018 at 4:41 am #
Free 17-day crash ×
Hi, Adrian, thank you for your effort. when i run the project, i meet Free
the problem
17-day ‘Unknown layeron
crash course type Shape in op
Computer
course on Computer
feature_fusion/Shape in function populateNet ‘. and in my computer ‘net = cv2.dnn.readNet(args[‘east’])’
Vision, OpenCV, and Deep Learningbe replaced
should
by the ‘net = cv2.dnn.readNetFromTensorflow(args[‘east’])’, i have installed the Opencv3.4.2, could tell me how to solve the
Vision, OpenCV, and
problems? Thank you so much!!!
Deep Learning
Interested in computer vision, OpenCV, and
Adrian Rosebrock August 24, 2018 at 8:30 am # deep learning, but don't know where toREPLY
Email
yes using cv2.dnn.readNetFromTensorflow still working. if your Address
using same camera for two python files
which calls as sub process , the opencv versions above 3.2 the camera release function doesn’t work after i mailed ✕
👋 Hey there! Which of these best describes
to opencv they told me to install opencv 4.0-alpha but couldn’t find a START
way to MY
you?
install in myCOURSE
EMAIL anaconda environment
Click to answer
after searching opencv 3.4.0.14 contains readNEtFromTensorflow and camera release function working
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 27/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
thank you
REPLY
Adrian Rosebrock October 8, 2018 at 12:54 pm #
REPLY
lxc August 26, 2018 at 9:21 pm #
Hi Adrian,
Why, scores and geometry’s shape are [1 180 80] [1 5 80 80]
REPLY
lxc August 26, 2018 at 9:25 pm #
oo,321/4=80
REPLY
Tom August 27, 2018 at 10:52 pm #
Hi Adrian
I made a few mods to the code and created a few different NMS implementations that will accept rectangles, rotated
rectangles or polygons as input.
tom
Vision, OpenCV, and
Deep Learning
Interested in computer vision, OpenCV, and
REPLY
Adrian Rosebrock August 28, 2018 at 3:15 pm # deep learning, but don't know where to
start? Let me help. I've created a free, 17-day
This is awesome, thank you so much for sharing Tom!
crash course that is hand-tailored to give you
the best possible introduction to computer
vision and deep learning. Sound good? Enter
your email below to get started. REPLY
Tom August 29, 2018 at 10:53 pm #
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 28/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
nms.readthedocs.io
REPLY
Sébastien August 28, 2018 at 9:15 am #
REPLY
Adrian Rosebrock August 28, 2018 at 3:07 pm #
Technically yes. For this algorithm you would compute the bounding box for all detected bounding box
coordinates. From there you could extract the region as a single text box.
REPLY
Sébastien August 29, 2018 at 2:54 am #
REPLY
Adrian Rosebrock August 30, 2018 at 9:04 am #
Figure 1 shows examples of images that would be very challenging for text detectors to detect. You could
determine two lines based on the bounding boxes supplied by the text detector — one for the first line and a second
bounding box for the second line.
REPLY
Sébastien September 4, 2018 at 2:13 am #
Free 17-day crash ×
Thanks! Free 17-day crash course on Computer
course on Computer
Vision, OpenCV, and Deep Learning
Vision, OpenCV, and
pankaj sharma August 30, 2018 at 9:07 am # Deep Learning REPLY
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 29/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Double-check your OpenCV version. You will need at least OpenCV 3.4.1 to run this script (it sounds like you have an
older version).
REPLY
pankaj sharma August 30, 2018 at 9:17 am #
REPLY
Adrian Rosebrock August 30, 2018 at 9:45 am #
Did you install OpenCV with the contrib module enabled? Make sure you are following one of my
OpenCV install tutorials.
REPLY
Joan September 2, 2018 at 11:51 am #
REPLY
Hassan January 30, 2019 at 6:28 am #
REPLY
Adrian Rosebrock February 1, 2019 at 7:11 am #
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 30/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
I’ll be covering exactly how to do this process in a future blog post but in the meantime I always recommend
experimenting. Your approach is a good one, I recommend you try it and see what types of results you get.
REPLY
sidis September 3, 2018 at 2:03 am #
Hi Adrian
is this possible to recognise the test
REPLY
Adrian Rosebrock September 5, 2018 at 8:59 am #
Once you’ve detected text in an image you can apply OCR. I’ll be covering the exact process in a future
tutorial, stay tuned!
REPLY
Matheus Cunha September 4, 2018 at 1:57 pm #
Is there any way to use the video text detecion using the Raspberry Camera V2?
REPLY
Adrian Rosebrock September 5, 2018 at 8:34 am #
REPLY
Dany September 5, 2018 at 5:27 am #
Very intresting! It’s possible to convert in real text with OpenCV or I need to use OCR?
Thanks.
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 31/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
For anyone who is following along with this post, here is the link to the text detection + OCR post I
was referring to.
REPLY
Prince Bhatia September 10, 2018 at 7:46 am #
How to print probability that this image has this much 99 percent probability it has text? or image has 0 percent
probability that it does not has text?
REPLY
Adrian Rosebrock September 11, 2018 at 8:13 am #
Are you referring to a specific region of the image having text? Or the image as a whole?
REPLY
mohamed September 10, 2018 at 9:19 am #
Hi Adrian
I apologize for my inaccurate questions
But I would like to know why the attached form in the downloads is less accurate than the model in the warehouse
recommended by the team. in this place:
(https://github.com/argman/EAST)
Have you modified something to comply with opencv?
Free 17-day crash ×
Free 17-day crash course on Computer
course on Computer
Vision, OpenCV, and Deep Learning
Adrian Rosebrock September 11, 2018 at 8:11 am # Vision, OpenCV, and REPLY
Deep Learning
The method I’ve used here is a port of the EAST model. As I’ve mentioned in the blog post the code itself
cannot computed the rotated bounding boxes.
Interested in computer vision, OpenCV, and
deep learning, but don't know where to
start? Let me help. I've created a free, 17-day
Gaurav A September 11, 2018 at 5:37 am # crash course that is hand-tailored to give you
REPLY
REPLY
Adrian Rosebrock September 11, 2018 at 8:01 am #
If your image is “clean” enough you can perform simple image processing via thresholding/edge detection and
contours to extract the digit. For more complex scenes you may need some sort of semantic segmentation. Stay tuned
for next week’s blog post where I’ll be discussing how you can actually OCR the text detected by EAST.
REPLY
Hochan September 11, 2018 at 9:35 pm #
If you are interested in making your own model and import it to opencv, check this link.
https://github.com/opencv/opencv/issues/12491
REPLY
Sushil September 12, 2018 at 7:58 am #
Hello adrian, Your work is really amazing!! I’m getting some issues with final bounding boxes after
nonMaxSupression. I’m getting almost all characters before supression, but in final result some characters are not
considered in the bounding boxes because of supression algorith. So, I thought about taking only outer boxes(implementing
own algorithm) But ‘rects’ have so many x-y co-ordinates i’m unable to get which co-ordinates are of one box and which are
of the other boxes. Do you have any suggestion or solution for this?
REPLY
Adrian Rosebrock September 12, 2018 at 1:51 pm #
The “rects” list is just your set of bounding box coordinates so I’m not sure what you mean by being unable to
get coordinates belong to which box. Each entry in “rects” is a unique bounding box.
Deep Learning
Adrian Rosebrock September 18, 2018 at 7:14 am # Interested in computer vision, OpenCV,REPLY
and
deep learning, but don't know where to
Be sure to refer to the re-implementation of the EAST model for moreLet
start? information on the
me help. I've dataset
created and 17-day
a free, training
procedure. crash course that is hand-tailored to give you
the best possible introduction to computer
vision and deep learning. Sound good? Enter
your email below to get started.
REPLY
Rohan September 18, 2018 at 7:09 pm #
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 33/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Thanks
REPLY
Arindam September 25, 2018 at 11:59 am #
Hey Adrian,
The article was really helpful. I was wondering if you could guide me with segregating handwritten text and machine printed
text in a picture of a document.
REPLY
Jonathan Salama September 28, 2018 at 2:39 pm #
Hello, I was wondering if there is a version that would output the actual text observed. Thanks!
REPLY
Adrian Rosebrock October 8, 2018 at 12:19 pm #
REPLY
Suresh Doraiswamy September 30, 2018 at 8:57 am #
When you run Adrian’s text_Detection.py using Python 3.6 and OpenCV 3.4.3 on Windows 10,
If the line, <> shows an error saying cv2.dnn does not have readNet as a valid function, then you can do the following and
eliminate the error:
It’s great blog post. crash course that is hand-tailored to give you
the best possible introduction to computer
Currently, I’m working on a project that is related with detect object in technical
visiondrawing image
and deep (eg. CAD
learning. scan
Sound image).
good? So I
Enter
need to detect lines, numbers, text in image.
your email below to get started.
I tested with your code in this blog. But the accuracy seems not good.
If you have any idea to improve, please share with me ! Email Address
✕
👋
Hey there! Which of these best describes you?
image example here: https://imgur.com/a/PN5J6CJ
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 34/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Thanks
REPLY
Chris October 2, 2018 at 11:53 pm #
Adrian, how did you freeze the model, ( convert .ckpt to .pb )?
REPLY
Adrian Rosebrock October 8, 2018 at 10:29 am #
Are you asking how to convert a TensorFlow model to OpenCV format? If you can clarify I can point you in the
right direction.
REPLY
Chris October 27, 2018 at 12:15 pm #
When training EAST, the created model is in .ckpt, how to convert that .ckpt model to .pb so that I am able
to use in your opencv version of EAST?
REPLY
Adrian Rosebrock October 29, 2018 at 1:33 pm #
Refer to the official OpenCV documentation — they include scripts to covert the model to make it
compatible with OpenCV directly.
REPLY
Dekker October 2, 2018 at 11:59 pm #
https://github.com/vinayakkailas/Deeplearning-OCR
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 35/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
REPLY
Adrian Rosebrock October 8, 2018 at 10:15 am #
REPLY
Ritika October 10, 2018 at 7:53 am #
Hi!
Thanks for sharing the frozen model for east text detector.
I am currently working on a project where I need to use the tensorflow Lite model for mobile application. To convert the
frozen model to tf lite I need to know the names of the input and output tensors. Could you please provide me with the
same?
Thanks
REPLY
Adrian Rosebrock October 12, 2018 at 9:16 am #
Hey Ritika — I would suggest reaching out to the authors of the EAST paper model (linked to in this blog post).
They will be able to provide more suggestions into the model and layer naming conventions.
REPLY
Bragg Xu October 17, 2018 at 1:28 am #
Thanks for sharing. I‘m using opencv3.4.1 with python on Mac, is it ok for the version requirement?
REPLY
Adrian Rosebrock October 20, 2018 at 7:57 am #
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 36/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Best regards,
Tobi
REPLY
Adrian Rosebrock October 20, 2018 at 7:45 am #
Take a look at the EAST publication that I linked to in the post. You also might want to look at the architecture
visualization and see how the volume size changes as data passes through the network. As for your second question, I
think you’re asking where to learn trigonometry? Let me know if I understood your question correctly.
REPLY
Tobi November 2, 2018 at 5:26 am #
Hi Adrian,
Best regards,
Tobi
REPLY
Saurav October 20, 2018 at 12:24 pm #
Hi,
Thank so much for posting this and sharing your knowledge. I love reading your post. This code works very well.
I was wondering is there any way to detect blocks for a single line at a time.
×
REPLY
Xiaodan October 20, 2018 at 5:42 pm #
Free 17-day crash
Thanks for posting! Great article. One question, could I use EASTFree 17-day crash
text detector to onlycourse
detect on Computer
digits?
course on Computer
Vision, OpenCV, and Deep Learning
Vision, OpenCV, and
Adrian Rosebrock October 22, 2018 at 8:09 am #
Deep Learning REPLY
Interested
EAST doesn’t provide you with any context of what the text actually in computer
contains, only that vision, OpenCV,
text exists and
somewhere
deep learning, but don't know where
in an image. Therefore, no, you cannot instruct EAST to detect digits. Instead, you would want to perform text to
recognition and then use Tesseract to return only digits. start? Let me help. I've created a free, 17-day
crash course that is hand-tailored to give you
the best possible introduction to computer
vision and deep learning. Sound good? Enter
REPLY
Xiaodan October 22, 2018 at 8:50 pm # your email below to get started.
Could I replace the training data (presumably English text training data) with digit (math formula training
Email Address
data) and train the same architecture? My purpose is to build an app that can detect then recognize and grade math
✕
👋
worksheet problems from Hey there! Which of these best describes you?
photos.
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 37/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
REPLY
Adrian Rosebrock October 29, 2018 at 2:16 pm #
Presumably yes but you’ll also want to refer to the official EAST GitHub repo that I linked to inside the
post.
REPLY
ali October 24, 2018 at 12:15 am #
Hi, Adrian
Thanks for sharing, I have problem when I run the codes on my Pi with webcam suddenly my Pi restarting
please help me to slove this problem 🙁
REPLY
Adrian Rosebrock October 29, 2018 at 2:04 pm #
It sounds like your Pi may be becoming overheating and is restarting or there is some sort of physical issue
with your Raspberry Pi. Can you try with a different Pi?
REPLY
Atul Mahajan October 26, 2018 at 8:23 am #
I want to read the detected text from live video and for this I thought of first separating the frame in which text is detected
and then apply OCR on frame to read the text. But I observed to identify the frame it is very slow and time consuming
process.
Could you please suggest fast solution to read text from live video.
REPLY
Adrian Rosebrock October 29, 2018 at 1:41 pm #
REPLY
Adrian Rosebrock October 29, 2018 at 1:05 pm #
Email Address
✕
👋Hey there! Which of these best describes
I linked to the C++ implementation from my original blog post. Make sure you’re reading the full post.
you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 38/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
REPLY
Wim van de Brug October 30, 2018 at 6:09 am #
Hi Adrian,
Thanks for this great post. I have set up an environment using Python 3.7.1 and OpenCV 3.4.3.18 (from your pip install
opencv post). The script runs like a charm but rather slow:
[INFO] loading EAST text detector…
[INFO] text detection took 0.569462 seconds
I run this on a Microsoft Surface Pro 4 Windows 10 in the most minimal virtual env required for this script. Why is it on
Windows10 that slow compared to your benchmark?
Wim
REPLY
Adrian Rosebrock November 2, 2018 at 8:25 am #
Hey Wim — I’m not sure why the code would be so much slower on a Surface Pro. I’m not personally familiar
with the hardware.
REPLY
Pallawi November 19, 2018 at 8:54 am #
Hi Adrian,
Thank you for such a great blog.
The texts are very small and when I pass the whole slip into EAST, It does not give a correct detection.
I wanted to ask:
Email Address
✕
👋Hey
Adrian Rosebrock there!
November Which
20, 2018 of# these best describes you?
at 9:01 am
START MY EMAIL COURSE
REPLY
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 39/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
For more details on the EAST CNN architecture be sure to refer to their official GitHub.
REPLY
Dorra November 20, 2018 at 10:26 am #
Adrian I mean that you did not use neither “LeNet” , “AlexNet” , “ZFNet” , “GoogLeNet” , “VGGNet” or
RestNet ?
REPLY
Adrian Rosebrock November 21, 2018 at 9:36 am #
Again, kindly refer to the GitHub link and associated paper I have provided you with. Read them and
your question will be answered.
REPLY
Andrew November 28, 2018 at 7:48 pm #
Thank you!
REPLY
Adrian Rosebrock November 30, 2018 at 9:04 am #
You need to convert your TensorFlow model to OpenCV format using OpenCV’s TensorFlow conversion tools.
To be honest I’ve never tried that process so I cannot give you instructions on how to proceed.
REPLY
Akin November 29, 2018 at 5:54 pm # Email Address
✕
Hi Adrian, 👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
Thanks for this and many other great posts! Learning a lot.
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 40/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
I wonder if there is a way to get more precise bounding boxes around words (or even letters).
I can see on your demo that EAST is pretty powerful for detecting the ‘general’ region where the text lies (and then we have
powerful tools to infer the ‘content’ of the text from there), but if I wanted to have ‘coordinates’ or ‘height’ of the letters or
words,
the current code would not be enough.
REPLY
San December 16, 2018 at 1:12 am #
You can just extract the startX, startY, endX, endY from the code. Do some simple coding, like center points
(i.e: (startX + endX) / 2 ))
REPLY
San December 16, 2018 at 1:09 am #
Hi, thanks for writing this one. Are there any way that I can retrain this network?
Thanks
San
REPLY
Adrian Rosebrock December 18, 2018 at 9:08 am #
You would need to refer to the documentation provided by the EAST text detection GitHub repo.
Email Address
✕
👋Hey there! Which of these best describes
Ishan December 28, 2018 at 7:46 am #
you?
START MY EMAIL COURSE
REPLY
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 41/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
REPLY
Adrian Rosebrock January 2, 2019 at 9:40 am #
REPLY
Nishtha January 3, 2019 at 2:31 am #
REPLY
Adrian Rosebrock January 5, 2019 at 8:54 am #
Are you SSH’ing into your system? If so, make sure you enable X11 forwarding:
$ ssh -X user@your_ip_address
REPLY
Ahmed January 4, 2019 at 1:32 pm #
Hi Adrian,
My laptop’s Cpu is getting used 100% after running text detection video script .. is it normal?
Email Address
✕
👋Hey
Adrian Rosebrock there!
January 8, 2019 atWhich
6:35 am #of these best describes you?
START MY EMAIL COURSE
REPLY
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 42/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Double-check your path to the input image. The path is invalid and “cv2.imread” is returning “None”. You can
read more about NoneType errors, including how to resolve them, here.
REPLY
CGMoon January 11, 2019 at 3:35 am #
Thank you very much for your good writing and code.
If the size of the input image is 672 x 512, how do you think about resizing the width and height to the nearest size while
maintaining a multiple of 32?
I am wondering which case in the resize case below shows the best result.
– case 1: 640 x 480 (both width and height are multiples of 32 and resize to nearest size)
– case 2: 640 x 640 (the width is a multiple of 32 and the height resizes to the same size as the width)
– case 3: 480 x 480 (the height is a multiple of 32, resize to the same size as the width)
REPLY
Zoylamb January 18, 2019 at 2:59 am #
Hello,
Thank you for this tutorial. I’m willing to use another frozen model and i would like to know how to choose the output name?
“feature_fusion/Conv_7/Sigmoid”,
“feature_fusion/concat_3”
Thank you.
REPLY
Adrian Rosebrock January 22, 2019 at 9:41 am #
Email Address
✕
👋Hey
Adrian Rosebrock there!
January 22, 2019 Which
at 9:38 am of
# these best describes you?
START MY EMAIL COURSE
REPLY
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 43/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
I’m using an iMac Pro with a 3Ghz Intel Zeon W processor. The Raspberry Pi will be FAR too slow to run this code (it
just doesn’t have enough computational horsepower).
REPLY
Abi January 21, 2019 at 9:36 am #
Hi,
Can i opencv-3.3.0 to run this code. Or anyways to upgarde version 3.3 to 4. Since i have already installed 3.3.
REPLY
Adrian Rosebrock January 22, 2019 at 9:19 am #
You’ll need either OpenCV 3.4 or OpenCV 4 for this tutorial. Make sure you upgrade from OpenCV 3.3.
REPLY
Jerome Diongon January 22, 2019 at 11:39 pm #
————–
usage: text_detection_video.py [-h] -east EAST [-v VIDEO] [-c MIN_CONFIDENCE]
[-w WIDTH] [-e HEIGHT]
text_detection_video.py: error: the following arguments are required: -east/–east
————–
that’s the error i got when i run the code. please answer thank you 🙂
REPLY
Adrian Rosebrock January 25, 2019 at 7:32 am #
It’s okay if you are new to Python and command line arguments but you need to read this tutorial first. From
there you’ll understand command line arguments and be able to execute the script.
Email Address
REPLY ✕
👋Hey
Adrian Rosebrock there! Which of these best describes you?
January 29, 2019 at 6:28 am #
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 44/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
See this tutorial where I extract the bounding box of the text and pass it through the OCR engine. Once you have the
bounding box you can mask the text.
REPLY
Manoj January 29, 2019 at 10:15 am #
REPLY
Adrian Rosebrock February 1, 2019 at 7:29 am #
You’re trying to compute a mask for the actual text then? That sounds more like an instance
segmentation problem. I don’t know of any instance segmentation models for pure text though, you may need to
do some research there.
REPLY
Ray Li January 29, 2019 at 10:02 am #
REPLY
Adrian Rosebrock February 1, 2019 at 7:26 am #
Thanks very much for these interesting blogs. Interested in computer vision, OpenCV, and
But I am a little bit disappointed in openCV 🙁 as this text detector doesn’tdeep
perform well onbut
learning, angled orknow
don't small where
text. And
to
sometimes tesseract can’t recognise or makes no sense as the text detector couldn’t
start? make
Let me an I've
help. accurate region
created proposal
a free, 17-dayin
the first step. crash course that is hand-tailored to give you
I made some improvements based on your code by letting tesseract searchthe
a little
bestbit aroundintroduction
possible the proposed text region. It is
to computer
more accurate but a bit less efficient.
vision and deep learning. Sound good? Enter
your email below to get started.
✕
👋Hey
your code has a small bug. Thethere! Which
bounding box willof
bethese best
overflow describes
in some cases.
START
you?
MY To that you
EMAIL should do
COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 45/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
after
REPLY
vinoth kumar February 2, 2019 at 1:32 am #
REPLY
Adrian Rosebrock February 5, 2019 at 9:40 am #
REPLY
Muhammad Khisal Khalid February 4, 2019 at 10:46 am #
Hey,
Thank you for the great Article. It helped me a lot in learning. This works perfectly for the normal orientation. Please tell me
what changes do I need if the letters are upside down or sideways. I
REPLY
Nike February 5, 2019 at 12:58 am #
How to unfreeze frozen_east_detection.pb into actual model. I actually wanted to see the coding behind it. I am a
beginner in this field. Wanted to know what is happening behind the scene.
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 46/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
REPLY
rahul February 12, 2019 at 3:27 am #
REPLY
Adrian Rosebrock February 14, 2019 at 1:21 pm #
Refer to the GitHub repo referenced in the body of the blog post. Follow the instructions from the authors
(again, in the GitHub repo I linked to).
REPLY
Hershel February 12, 2019 at 11:39 am #
Hi Adrian,
This is the first neural net I’ve seen where the size of the image just had to be a multiple of a number rather than a specific
dimension. I’ve looked through the East Github page and am not seeing the mechanism that allows that to happen.
I’ve tested this code out on images of size 8384 x 1600 (email ad) and it works beautifully, so clearing it isn’t just resizing to
32 x 32.
Is this so obvious that I’m overlooking it? Do you know of any papers or documentation that I could look into?
REPLY
Jerome Diongon February 26, 2019 at 10:18 am #
Good day! How can i get the result of the captured character in the video? Because i want to put it in a text file.
Hope you can answer me, thank you :).
REPLY
Adrian Rosebrock February 27, 2019 at 5:37 am #
Free 17-day crash ×
No problem, just refer to this tutorial.
Free 17-day crash course on Computer
course on Computer
Vision, OpenCV, and Deep Learning
Vision, OpenCV, and
REPLY
Jerome Diongon March 3, 2019 at 1:45 am # Deep Learning
How about if I want to send the captured characters in theInterested
database, in
how is it?
computer vision, OpenCV, and
deep learning, but don't know where to
start? Let me help. I've created a free, 17-day
crash course that is hand-tailored to give you
REPLY
Adrian Rosebrock March 5, 2019 at 8:57 am #
the best possible introduction to computer
vision and
That’s not really a computer vision problem. That’s a general deep learning. Sound good?
programming/engineering Enter
problem. I
your emailand
would recommend you take the time to read up on Python programming below to get
basic started. From there you
databases.
can continue with your project.
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer REPLY
Anshul jain March 5, 2019 at 3:00 am #
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 47/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
REPLY
Adrian Rosebrock March 5, 2019 at 8:28 am #
You mean the dataset the EAST model was trained on? Refer to the author’s GitHub page which I’ve linked to
from the body of the post.
REPLY
Aadesh March 15, 2019 at 9:54 pm #
Greetings Adrian,
Thank you for writing a great article. This is the first time i have worked with neural networks and while i was going through
your tutorial i found out that the dimension of the input image should be a multiple of 32. I referred the IEEE Paper of the
EAST Algorithm but i couldn’t figure out why the input has to be a multiple of 32. It would be great if you have any
documentations regarding this.
Thank You.
REPLY
Henry March 18, 2019 at 6:46 pm #
If I am only interested in number detection(from 0-9), is there any way for me to retrain the model? Or how do I
eliminate other texts except numbers with the current model?
REPLY
Adrian Rosebrock March 19, 2019 at 9:56 am #
Take a look at the Tesseract documentation. There is a set of parameters you can supply to only extract digits
(but I can’t remember it off the top of my head, sorry).
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE REPLY
Adrian Rosebrock March 22, 2019 at 8:29 am Click
# to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 48/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
You would want to define a heuristic to group them, such as “all bounding boxes within N pixels of each other
should be grouped together”. Loop over the bounding boxes, check to see if any are close, and if so, group
them.
REPLY
Nate March 24, 2019 at 10:16 pm #
Following from the previous question. How would one structure the code to group bounding boxes for individual text
detection and output?
Thanks in advance
REPLY
Adrian Rosebrock March 27, 2019 at 8:58 am #
What do you mean by “group bounding boxes”? How should the bounding boxes be grouped?
REPLY
Anshul jain March 27, 2019 at 2:29 am #
Great article but can you provide the dataset for static text detection or any source where i can get it?
REPLY
Vasil Dimitrov April 8, 2019 at 1:49 am #
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 49/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
REPLY
Sophie April 20, 2019 at 1:16 pm #
REPLY
Adrian Rosebrock April 25, 2019 at 9:15 am #
It sounds like you’re copying and pasting the code. Don’t do that. You likely inserted an error accidentally when
copying and pasting. Use the “Downloads” section of the post to download the code.
REPLY
Pradipta Karmakar April 26, 2019 at 9:28 am #
It was really a great and amazing project. I just want a little help as i am not that much expert in python coding for
image processing. Can anybody help me to show the text that is being detected???
REPLY
Adrian Rosebrock May 1, 2019 at 12:02 pm #
REPLY
Art April 27, 2019 at 2:26 pm #
Hi Adrian!
Has anybody done optimization of your implementation using Cython? Do you know?
Free 17-day crash ×
Free 17-day crash course on Computer
course on Computer
Vision, OpenCV, and Deep Learning
Vamsi May 30, 2019 at 12:27 pm # Vision, OpenCV, and REPLY
How do we store the detected text by time frame?
Deep Learning
Like
Interested in computer vision, OpenCV, and
Time: 0:39:43
deep learning, but don't know where to
Text: Prey
start? Let me help. I've created a free, 17-day
crash course that is hand-tailored to give you
the best possible introduction to computer
Adrian Rosebrock June 6, 2019 at 8:47 am # vision and deep learning. Sound good? Enter
REPLY
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 50/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Hi I need to build a model to extract handwriting from images, please suggest me how much will i be benefited if i
consult the described model or if not please suggest that as well.
Thanks in advance
Vivek
REPLY
Adrian Rosebrock June 13, 2019 at 9:34 am #
Trying to create a handwriting recognition system from scratch can be super challenging (and not something I
really recommend). Have you tried using an off-the-shelf solution such as Google Vision API yet? It includes a text
recognition component which may work for you.
REPLY
mick June 13, 2019 at 4:08 am #
Hi,
I i’m new to opencv (and using open cv sharp :s) and managed to implement you code in c# – but… I have an issue and
wondered if you knew in general why the scores and geometry rows and cols are both -1
Thanks
REPLY
Adrian Rosebrock June 13, 2019 at 9:32 am #
Congrats on implementing the text detector in C#, Mick! However, I’m not sure why that would happen. It may
be an issue with the C# OpenCV bindings but I’m not familiar with the C# + OpenCV bindings so unfortunately I don’t
have any suggestions on the issue.
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 51/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Thank you
REPLY
Manju August 2, 2019 at 4:14 am #
In response to the -1 in the c# code, there is actually something wrong width the Width/heigth property in
the opencvsharp wrapper. If you use the Property Size() and than X and Y it works fine.
REPLY
somesh bachani June 13, 2019 at 4:24 pm #
hello Adrian
after the text detection how do I convert the data into text like if on the image it say hello i need the output to be hello so i
can execute functions after comparision of the 2 strings please help
REPLY
Adrian Rosebrock June 19, 2019 at 2:24 pm #
REPLY
Denys June 17, 2019 at 4:26 pm #
Hi Adrian,
Thank you very much for such an amazing course! You’re Genious!
Could you please help, how to use EAST text detection with GRAYSCALE image?
Many thanks.
REPLY
Adrian Rosebrock June 19, 2019 at 2:02 pm #
Free 17-day crash ×
Just stack the gray image 3 times to create a 3-channel image:
Free 17-day crash course on Computer
course on Computer
Vision, OpenCV, and Deep Learning
image = np.dstack([gray, gray, gray])
Vision, OpenCV, and
Deep Learning
REPLY
Denys June 20, 2019 at 2:44 pm # Interested in computer vision, OpenCV, and
deep learning, but don't know where to
Thank you very much!
start? Let me help. I've created a free, 17-day
crash course that is hand-tailored to give you
the best possible introduction to computer
Adrian Rosebrock June 26, 2019 at 1:51 pm # vision and deep learning. Sound good? Enter
REPLY
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE REPLY
Franco June 23, 2019 at 11:31 am # Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 52/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Hi Adrian this is great content! One question though for my application it would be interesting to understand how to
generate a boolean that indicates if there is any text at all in the image. What would you suggest for this
application?
REPLY
Adrian Rosebrock June 26, 2019 at 1:32 pm #
Loop over all text detections and check to see if there is any detection that has a > X% confidence (you define
X% yourself). If so, set the boolean to True.
REPLY
SATYAM SAREEN June 23, 2019 at 5:26 pm #
Can you tell me what are these rows and columns in the scores volume as score contains the probability whether text is
present or not.
What is xdata0,xdata1,xdata2,xdata3,xdata4.
and my last doubt is I did not understood your step of calculating h,w, endx, endy, startx, starty.
Regards
Satyam Sareen
REPLY
aisha July 3, 2019 at 4:08 am #
hi adrian i want to try this code OpenCV Text Detection (EAST text detector) and i have downloaded it from here,
but where is the datset? can you please provide me the dataset?
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 53/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
REPLY
Sparsh_03 July 17, 2019 at 1:44 am #
HI Adrian , First of all thanks for the brilliant post , I want to detect the text only on the number plates leaving the
rest , how i could achieve this .
Thanks in advance
REPLY
Adrian Rosebrock July 25, 2019 at 9:51 am #
I cover ANPR/ALPR inside the PyImageSearch Gurus course. I suggest you start there.
REPLY
Alison C August 3, 2019 at 5:01 pm #
How can I have a text detection and text recognition in one poject?
please I need your help!!
REPLY
Adrian Rosebrock August 7, 2019 at 12:30 pm #
REPLY
Nazim Shaikh August 4, 2019 at 12:18 am #
I am trying to use the c++ version of this (provided by opencv) to detect lines, although I am having trouble understanding
that for line detection. Could you please help me on how I can detect lines of words using your script? Probably I can then
try to convert it into c++
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 54/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
Name (required)
Website
SUBMIT COMMENT
Search...
Get your FREE 17 page Computer Vision, OpenCV, and Deep Learning Resource Guide PDF. Inside you'll find my
hand-picked tutorials, books, courses, and libraries to help you master CV and DL.
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 55/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
You can teach your Raspberry Pi to “see” using Computer Vision, Deep Learning, and OpenCV. Let me show you how.
Deep Learning for Computer Vision with Python Book — OUT NOW!
You're interested in deep learning and computer vision, but you don't know how to get started. Let me help. My new book will teach you all
you need to know about deep learning.
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 56/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
The PyImageSearch Gurus course is now enrolling! Inside the course you'll learn how to perform:
Click the button below to learn more about the course, take a tour, and get 10 (FREE) sample lessons.
I'm Ph.D and entrepreneur who has spent his entire adult life studying Computer Vision and Deep Learning. I'm here to
help you master CV, DL, and OpenCV. Learn More
Email Address
Subscribe via RSS
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Never miss a post! Subscribe to the PyImageSearch RSS FeedClick
andtokeep
answer
up to date with my image search engine tutorials, tips, and tricks
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 57/58
8/27/2019 OpenCV Text Detection (EAST text detector) - PyImageSearch
POPULAR
Home surveillance and motion detection with the Raspberry Pi, Python, OpenCV, and Dropbox
JUNE 1, 2015
Email Address
✕
👋Hey there! Which of these best describes you?
START MY EMAIL COURSE
Click to answer
https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/ 58/58