get text from image python

img = cv2.imread('image.png')

text = pytesseract.image_to_string(img)
print(text)

Here is what the above code is Doing:
1. We’re loading the image into memory using the cv2.imread function.
2. We’re using the pytesseract.image_to_string function to convert the image into text.
3. We’re printing the text to the console.