JaidedAI / EasyOCR

Ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic and etc.
https://www.jaided.ai
Apache License 2.0
23k stars 3.03k forks source link

compute_ratio_and_resize passes a PIL constant to a cv2 function #1208

Open andreaswimmer opened 5 months ago

andreaswimmer commented 5 months ago

utils.py contains the following code https://github.com/JaidedAI/EasyOCR/blob/c999505ef6b43be1c4ee36aa04ad979175178352/easyocr/utils.py#L566-L577

Note that Image is part of PIL https://github.com/JaidedAI/EasyOCR/blob/c999505ef6b43be1c4ee36aa04ad979175178352/easyocr/utils.py#L7-L8

Since both of these map to an integer, this is not a type error. However PIL maps LANCZOS to 1 (https://github.com/python-pillow/Pillow/blob/e47877587fb8aa1853ef7473285a2964f5e98520/src/PIL/Image.py#L158-L164 ), while a 1 means bilinear interpolation in opencv (https://docs.opencv.org/3.4/da/d54/group__imgproc__transform.html )

daniellovera commented 2 months ago

Good find. Did you try changing the code so it passes an integer value of 4 to the openCV function? If so, did you see any performance differences?

I'm going to test this and see if it improves anything.