mvoelk/ssd_detectors

Word cropping causing truncated reads

marcoromelli opened this issue · 2 comments

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.

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.

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.