EasyOCR icon indicating copy to clipboard operation
EasyOCR copied to clipboard

readtext() error: Assertion failed) !ssize.empty() in function 'resize'

Open ukolovda opened this issue 8 months ago • 3 comments

I've got this error.

Full error is:

Traceback (most recent call last):
  File "/home/ukolovda/projects/ocr/ocr.py", line 68, in <module>
    outs = reader.readtext(str(jpeg_file), detail = 0)
  File "/home/ukolovda/.local/lib/python3.10/site-packages/easyocr/easyocr.py", line 468, in readtext
    result = self.recognize(img_cv_grey, horizontal_list, free_list,\
  File "/home/ukolovda/.local/lib/python3.10/site-packages/easyocr/easyocr.py", line 383, in recognize
    image_list, max_width = get_image_list(h_list, f_list, img_cv_grey, model_height = imgH)
  File "/home/ukolovda/.local/lib/python3.10/site-packages/easyocr/utils.py", line 613, in get_image_list
    crop_img,ratio = compute_ratio_and_resize(crop_img,width,height,model_height)
  File "/home/ukolovda/.local/lib/python3.10/site-packages/easyocr/utils.py", line 574, in compute_ratio_and_resize
    img = cv2.resize(img,(model_height,int(model_height*ratio)), interpolation=Image.Resampling.LANCZOS)
cv2.error: OpenCV(4.11.0) /io/opencv/modules/imgproc/src/resize.cpp:4208: error: (-215:Assertion failed) !ssize.empty() in function 'resize'

I cannot attach the image by security reason.

ukolovda avatar Apr 14 '25 11:04 ukolovda

Could you post image dimensions? What portion of the image is the actual text?

brownsloth avatar Jun 21 '25 14:06 brownsloth

Could you post image dimensions? What portion of the image is the actual text?

Image size is 3024 (width) * 4032 (height). It have multiple blocks of text over entire content.

The error gone after I open the file in Microsoft Paint and save it to separate name. But it still occured with original file (photo from mobile phone).

ukolovda avatar Jun 24 '25 12:06 ukolovda

This is interesting. One possibility is theres some encoding issue or overwritten header in the image file while being saved on phone. Opening in MSPaint fixes that. But if thats so readtext() should have failed much earlier when it tries to load the image. So thats not the case.

Sorry I cant really think of much at this point without the image. Maybe someone else can comment.

Meanwhile when I get time I will try to take images from phone, corrupt them and then try easyocr to see if I can replicate the issue. If you can share anything about which software you used for saving or processing the image on phone that would be helpful.

Thanks.

brownsloth avatar Jun 24 '25 17:06 brownsloth