0% found this document useful (0 votes)
69 views3 pages

Computer Vision Assignment For Text Extraction

The document contains a Python code to perform optical character recognition (OCR) on an image. The code uses MSER detection to identify regions of interest in the grayscale image and then uses the easyocr library to recognize text within those regions. The output from running the code on the sample image contains 4 text strings that were recognized.

Uploaded by

ZARAR AIMAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views3 pages

Computer Vision Assignment For Text Extraction

The document contains a Python code to perform optical character recognition (OCR) on an image. The code uses MSER detection to identify regions of interest in the grayscale image and then uses the easyocr library to recognize text within those regions. The output from running the code on the sample image contains 4 text strings that were recognized.

Uploaded by

ZARAR AIMAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assighnment#1 -CV

Name: M. Hanzalah Hashmi

Reg #: FA20-BCS-015

Section: A

PYTHON CODE:
!pip install easyocr

# Import necessary libraries


import cv2
from google.colab.patches import cv2_imshow
import easyocr
# Load the input image
img = cv2.imread('/content/636318268614760881-IAT-Kettles7.jpg')
cv2_imshow(img)

# Convert the image to grayscale


gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2_imshow(gray)

# Perform MSER detection on the grayscale image


mser = cv2.MSER_create()
regions,_= mser.detectRegions(gray)
for region in regions:
x, y, w, h = cv2.boundingRect(region)
cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)

cv2_imshow(img)

#Perform OCR after MSER detection on image


reader=easyocr.Reader(['en','en'])
results=reader.readtext(gray)
for x in results:
print(x[1])

Output:
Bury
A576
Manchester A6
(A56)

You might also like