utils.py contains the following code
EasyOCR/easyocr/utils.py
Lines 566 to 577 in c999505
| | defcompute_ratio_and_resize(img,width,height,model_height): |
| | ''' |
| | Calculate ratio and resize correctly for both horizontal text |
| | and vertical case |
| | ''' |
| | ratio=width/height |
| | ifratio<1.0: |
| | ratio=calculate_ratio(width,height) |
| | img=cv2.resize(img,(model_height,int(model_heightratio)), interpolation=Image.Resampling.LANCZOS) |
| | else: |
| | img=cv2.resize(img,(int(model_heightratio),model_height),interpolation=Image.Resampling.LANCZOS) |
| | returnimg,ratio |
Note that Image is part of PIL
EasyOCR/easyocr/utils.py
Lines 7 to 8 in c999505
| | importcv2 |
| | fromPILimportImage, JpegImagePlugin |
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 )
1条答案
按热度按时间knpiaxh11#
好的发现。你尝试过改变代码,让它将整数值4传递给openCV函数吗?如果是的话,你看到了任何性能差异吗?
我打算测试一下,看看是否会有所改善。