Process OpenCV/NumPy images
masterSince OpenCV loads images in BGR format and pytesseract expects RGB, you must convert the color space before processing.
import cv2
import pytesseract
from PIL import Image
img_cv = cv2.imread('digits.png')
# Option 1: Convert BGR to RGB using OpenCV
img_rgb = cv2.cvtColor(img_cv, cv2.COLOR_BGR2RGB)
print(pytesseract.image_to_string(img_rgb))
# Option 2: Convert using Pillow
img_rgb = Image.frombytes('RGB', img_cv.shape[:2], img_cv, 'raw', 'BGR', 0, 0)
print(pytesseract.image_to_string(img_rgb))