Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"TypeError: Argument 'thresh' must be double, not bool" on Recognition Using CTC Model #141

Open
rorivy opened this issue Dec 3, 2020 · 2 comments

Comments

@rorivy
Copy link

rorivy commented Dec 3, 2020

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?

@ori30ffs
Copy link

ori30ffs commented Dec 7, 2020

pip install opencv-python==4.2.0.34 helped me

@kascesar
Copy link
Contributor

kascesar commented Dec 22, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants