问题
I have this
006.jpg image and
i tried following python code
I downloaded "eng" from tessdata_best and renamed it to "eng_best"
img = cv2.imread(file_path)
lang = "eng_best"
for img_scale_factor in range (1,8):
print(file_path, img_scale_factor)
img = cv2.resize(img,None,fx=img_scale_factor,fy=img_scale_factor)
hocr_data = pytesseract.image_to_pdf_or_hocr(img, extension="hocr", lang=lang, config="--dpi 1")
file_name = '{0:03d}_jpg_{1}_x{3}.{2}'.format(6, lang, "hocr", img_scale_factor)
with open(os.path.join(savediv, file_name), 'w+b') as f:
f.write(hocr_data)
print(" Output - {}".format(file_name))
I tried above code with varying img_scale_factor
from 1
upto to 7
which scale given image by that scale factor
Here are output files :
006_jpg_eng_best_x1.html
006_jpg_eng_best_x2.html
006_jpg_eng_best_x3.html
006_jpg_eng_best_x4.html
006_jpg_eng_best_x5.html
006_jpg_eng_best_x6.html
006_jpg_eng_best_x7.html
We can clearly observe that Output
From
img_scale_factor
1 to 2
- Increases ocr result.For
img_scale_factor
3
- best ocr result among all.From
img_scale_factor
4 to 7
- Decreases ocr result.
For that particular image img_scale_factor
3
gives best results.
How can we figure out which scale factor is best without checking ocr for every scale factor for some particular types of image ?
May be this can be solved by fixing minimun and maximum font size.
Is there any way to configure minimun and maximum font size ?
来源:https://stackoverflow.com/questions/62480172/tesseract-ocr-act-weird-while-scalling-up-image-size-how-to-know-which-scale-fa