Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# text detection
def contours_text(orig, img, contours):
for cnt in contours:
x, y, w, h = cv2.boundingRect(cnt)
# Drawing a rectangle on copied image
rect = cv2.rectangle(orig, (x, y), (x + w, y + h), (0, 255, 255), 2)
# Cropping the text block for giving input to OCR
cropped = orig[y:y + h, x:x + w]
# Apply OCR on the cropped image
config = ('-l eng --oem 1 --psm 3')
text = pytesseract.image_to_string(cropped, config=config)

This comment has been minimized.

Copy link

@DarkPhoen1x99 DarkPhoen1x99 commented Jun 12, 2020

what is the img paramenter for?
and what is the orig paramenter when i call contours_text function ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment