mvoelk / ssd_detectors

SSD-based object and text detection with Keras, SSD, DSOD, TextBoxes, SegLink, TextBoxes++, CRNN
MIT License
302 stars 85 forks source link

Word cropping causing truncated reads #17

Closed marcoromelli closed 5 years ago

marcoromelli commented 5 years ago

Hi @mvoelk ! First of all, thanks a lot for your work.

I found a problem using the code from SL_end2end_predict.ipynb. In my specific use case I want to read some long words (actually sequence of numbers). The detector has no problems and it extracts correctly the bounding box (verified plotting the content of boxes). The issue is that this long word is truncated by the function crop_words and so the output of the CRNN model is wrong.

It doesn't seem to me that cropping a long word is a good way to handle the situation. How do you think I can fix this?

Thanks.

mvoelk commented 5 years ago

The input sequence lenght of the CRNN model does not change with each bounding box.

In your case, increasing input_width should work, but it slows down recognition when dealing with short words only.

marcoromelli commented 5 years ago

This helps for sure. In my case also resizing the word in crop_words if it's too large is giving good results:

if width is not None:
    if word.shape[1] >= width:
        word = cv2.resize(word, (width-1, height), interpolation=cv2.INTER_CUBIC)
        if len(word.shape) < 3:
            word = word[..., np.newaxis]
    tmp_word = word[:,:width,:]
    word = np.ones([height, width, tmp_word.shape[2]])
    word[:,slice(0, tmp_word.shape[1]), :] = tmp_word

Thanks for your help.