Ive been trying to detect the white letters on a light blue background and it seems to work for same background but with slightly cleaner letters.
Here is the image - it returns no text from the OCR activity. If I make background darker blue, its OK. The text seems clear enough, maybe its some odd tesseract thing?
Thanks.
import cv2
import pytesseract
image = cv2.imread('c3.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.imshow('gray', gray)
thresh = cv2.threshold(gray,175 ,255, cv2.THRESH_BINARY_INV)[1]
thresh = 255 - thresh
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (3,3))
result = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel, iterations=1)
cv2.imshow('thresh', thresh)
cv2.imshow('result', result)
cv2.imwrite('result.jpg', result)
invert = cv2.bitwise_not(result)
config = ''
text = pytesseract.image_to_string(invert, config=config)
cv2.imshow('result', invert)
print("Result: " + text)
cv2.waitKey()
