handwriting-ocr
handwriting-ocr copied to clipboard
"TypeError: Argument 'thresh' must be double, not bool" on Recognition Using CTC Model
I am trying to run the model using the OCR notebook and I was able to run the code smoothly until the last cell. Its giving me the error "TypeError: Argument 'thresh' must be double, not bool" pointing to the last line of code. Am I missing something here?
pip install opencv-python==4.2.0.34 helped me
there are more sofisticated way. Need change some lines, that i did:
- return _crop_add_border(th, height, border, border_size)
- return _crop_add_border(th, height=height, border=border, border_size=border_size)
The function in question is "word_normalization", int "./src/ocr/normalization.py"
It will be like this:
def word_normalization(image, height, border=True, tilt=True, border_size=15, hyst_norm=False):
""" Preprocess a word - resize, binarize, tilt world."""
image = resize(image, height, True)
if hyst_norm:
th = _hyst_word_norm(image)
else:
img = cv2.bilateralFilter(image, 10, 30, 30)
gray = 255 - cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
norm = cv2.normalize(gray, None, 0, 255, cv2.NORM_MINMAX)
ret,th = cv2.threshold(norm, 50, 255, cv2.THRESH_TOZERO)
if tilt:
return _word_tilt(th, height, border, border_size)
return _crop_add_border(th, height=height, border=border, border_size=border_size)
Hope this helps