<jupyter_start><jupyter_text>**GRADUATE ROTATIONAL INTERNSHIP PROGRAM @THE SPARKS FOUNDATION**By:<NAME>**Task 1:Object Detection/Optical Character Recognition**Description:Character detector which extracts printed or handwritten text from an image or video Installation of easyocr<jupyter_code>!pip install easyocr<jupyter_output>Collecting easyocr
  Downloading easyocr-1.4.1-py3-none-any.whl (63.6 MB)
[K     |████████████████████████████████| 63.6 MB 19 kB/s 
[?25hRequirement already satisfied: torch in /usr/local/lib/python3.7/dist-packages (from easyocr) (1.9.0+cu102)
Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from easyocr) (1.4.1)
Requirement already satisfied: scikit-image in /usr/local/lib/python3.7/dist-packages (from easyocr) (0.16.2)
Requirement already satisfied: PyYAML in /usr/local/lib/python3.7/dist-packages (from easyocr) (3.13)
Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from easyocr) (1.19.5)
Requirement already satisfied: Pillow<8.3.0 in /usr/local/lib/python3.7/dist-packages (from easyocr) (7.1.2)
Collecting opencv-python-headless
  Downloading opencv_python_headless-4.5.3.56-cp37-cp37m-manylinux2014_x86_64.whl (37.1 MB)
[K     |████████████████████████████████| 37.1 MB 47 kB/s 
[?25hCollecting python-bidi
  Downloadi[...]<jupyter_text>Importing modules<jupyter_code>import easyocr
import cv2
import matplotlib.pyplot as plt
import numpy as np<jupyter_output><empty_output><jupyter_text>Reading text from images<jupyter_code>img_path="quote.jpg"
img=cv2.imread(img_path)
reader=easyocr.Reader(["en"],gpu=True)
result=reader.readtext(img_path)
plt.imshow(img)
plt.show()
print(result)<jupyter_output>Downloading detection model, please wait. This may take several minutes depending upon your network connection.<jupyter_text>Showing the results<jupyter_code>for detection in result:
  top_left=tuple([int(val) for val in detection[0][0]])
  bottom_right=tuple([int(val) for val in detection[0][2]])
  text=detection[1]
  font=cv2.FONT_HERSHEY_COMPLEX
  img=cv2.rectangle(img,top_left,bottom_right,(0,255,0),5)
  img=cv2.putText(img,text,top_left,font,1.2,(0,0,0),2,cv2.LINE_AA)
plt.imshow(img)
plt.show()
img_bg_path="bg.jpg"
img_bg=cv2.imread(img_bg_path)
img_bg=cv2.resize(img_bg,(500,500))
img_bg = cv2.cvtColor(img_bg, cv2.COLOR_BGR2RGB)
for detection in result:  
  top_left=tuple([int(val) for val in detection[0][0]])
  bottom_right=tuple([int(val) for val in detection[0][2]])
  text=detection[1]
  font=cv2.FONT_HERSHEY_COMPLEX  
  img=cv2.putText(img_bg,text,top_left,font,1.5,(0,0,0),2,cv2.LINE_AA)
plt.imshow(img_bg)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15479298769116, 'fraction_numerical': 0.047743379336068634, 'mean_word_length': 6.819241982507289, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '542071', 'license': 'MIT', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1051, 'n_words': 187, 'path': 'Task1.ipynb', 'repo_name': 'aromaljosebaby/OCR', 'size': '2691'}