Skip to content

Commit

Permalink
change psm for tesseract
Browse files Browse the repository at this point in the history
  • Loading branch information
刘亮均 authored and 刘亮均 committed Apr 22, 2020
1 parent 0b7d1bb commit bd363b2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ctpn_detect_v1/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


def img_to_string(image):
return pytesseract.image_to_string(image, config='-l eng+chi_sim --oem 3 --psm 3')
return pytesseract.image_to_string(image, config='-l eng+chi_sim --oem 3 --psm 7')


def crnnRec(im, text_recs, ocrMode='keras', adjust=False):
Expand Down Expand Up @@ -56,13 +56,13 @@ def crnnRec(im, text_recs, ocrMode='keras', adjust=False):

# 图片的长宽如果小于30px,则按比例放大
w, h = image.size
print(f'idx:{index}, w:{w}, h:{h}')
factor = 30 / min(image.size)
if factor > 1:
print('turn size...')
image = image.resize((int(w * factor), int(h * factor)))
image = image.resize((ceil(w * factor), ceil(h * factor)))

images.append(image)
# image.save(f'./temp/{index}.png')
# image.save(f'./{index}.png')

# 进行识别出的文字识别
# sim_pred = pytesseract.image_to_string(image, config='-l eng+chi_sim --oem 3 --psm 3')
Expand Down

0 comments on commit bd363b2

Please sign in to comment.