-1

I am new to opencv and ocr and I am writing a code in python opencv to apply text detection and ocr on this image where originally, pytesseract doesn't return any output.

this image

After trying to do some preprocessing, the imwrite() method doesn't write the ModifiedScan1 to file and nothing is done after that line, there is no output or no error. Can anyone please tell me how to get the text output of this image.

Below is the code:

import cv2
import pytesseract

img2 = cv2.imread("ScannedNameImage.jpg")
img3 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
img4 = cv2.threshold(img3, 127, 255, cv2.THRESH_BINARY)
cv2.imwrite("ModifiedScan1.jpg", img4)
img5 = cv2.imread("ModifiedScan1.jpg")
pytesseract.pytesseract.tesseract_cmd = r'C:\\Program Files\\Tesseract-OCR\\tesseract.exe'
image_to_character = pytesseract.image_to_string(img5)
print(image_to_character, end=" ")
Vitalizzare
  • 722
  • 1
  • 7
  • 18
  • https://stackoverflow.com/questions/32473095/image-to-text-recognition-using-tesseract-ocr-is-better-when-image-is-preprocess – Jeru Luke May 31 '22 at 06:11

0 Answers0