diff --git a/.DS_Store b/.DS_Store index d9a693e..063ceb4 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/main.py b/main.py index 046a304..a38512d 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ import pytesseract import os directory = 'images' +k = 1 # iterate over files in # that directory for filename in os.listdir(directory): @@ -15,6 +16,11 @@ for filename in os.listdir(directory): ROI1 = thresh[1383:1447,77:154] ROI2 = thresh[1383:1447,950:1027] ROI = cv2.hconcat([ROI1, ROI2]) - data = pytesseract.image_to_string(ROI, lang='eng',config='--psm 7 -c tessedit_char_whitelist=0123456789' ) + data = pytesseract.image_to_string(ROI, lang='eng',config='--psm 7 -c tessedit_char_whitelist=0123456789i' ) print(data) - os.rename(f'{f}', f'images/{data}.jpg') + if os.path.isfile(f'images/{data}.jpg') == False: + os.rename(f'{f}', f'images/{data}.jpg') + else: + os.rename(f'{f}', f'images/{data}.{k}.jpg') + k = k + 1 + cv2.destroyAllWindows()