Even though I followed the question KeyError: 'PNG' while using pytesseract.image_to_data, I couldn't resolve the problem.
I installed the tesseract in google colab.
!sudo apt-get install tesseract-ocrthen installed pytesseract=0.3.9
!pip install pytesseract==0.3.9this is my code:
import cv2 from pytesseract import Output from PIL import Image import pytesseract image = cv2.imread('0003.jpg') rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) results = pytesseract.image_to_data(rgb, output_type=Output.DICT)
but I get the error:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-25-21a4d6775e8a> in <module>
9 image = cv2.imread('/content/sample_data/0003.jpg')
10 rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
---> 11 results = pytesseract.image_to_data(rgb, output_type=Output.DICT)
12 for i in range(0, len(results["text"])):
13 x = results["left"][i]
5 frames
/usr/local/lib/python3.7/dist-packages/PIL/Image.py in save(self, fp, format, **params)
2121 expand=0,
2122 center=None,
-> 2123 translate=None,
2124 fillcolor=None,
2125 ):
KeyError: 'PNG'