0

I want to higlight string in the image. I am using easyocr to extract text from the image. Eayocr extracted text from image line wise.In one of the contour there are four words. Out of which I want to higlight one word. I am new to Easyocr , need help to do this.

Below is what I have done.

image = cv2.imread(img_path)
reader = Reader(['en'])
results = reader.readtext(image)

for (bbox, text, prob) in results:
       if any(word in text for word in search_str_list):
             mask = np.ones(image.shape[:2], dtype="uint8") * 255
             image_masked = cv2.bitwise_and(image, image, mask=mask)
             contours = np.array (bbox)
             image=cv2.fillPoly(image_masked, pts=[contours], color=(0,0,0))

if my contour has four words My name is Aditya and the word I want to highlight is Aditya, the with the above code, it is highlighting the full sentence or all 4 words.

I need to highlight only 'Aditya'.

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36

0 Answers0