How to do it...

Perform the following steps to implement text detection and recognition using the opencv-python functions:

  1. Define the following function to decode the predictions by EAST and extract the bounding boxes (locations of the texts detected) and associated confidences:
min_confidence = 0.5def decode_predictions(scores, geometry):       (num_rows, num_cols) = scores.shape[2:4]    rects, confidences = [], []    for y in range(0, num_rows):        scores_data = scores[0, 0, y]        x_data0, x_data1 = geometry[0, 0, y], geometry[0, 1, y]        x_data2, x_data3 = geometry[0, 2, y], geometry[0, 3, y]        angles_data = geometry[0, 4, y]        for x in range(0, num_cols):            if scores_data[x] < min_confidence: continue             (offset_x, offset_y) = (x * 4.0, y * 4.0)  angle = angles_data[x] ...

Get Python Image Processing Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.