From 9beebff9c63114799e67ec356e07fddfd1e3ccf4 Mon Sep 17 00:00:00 2001 From: Kabooshki Date: Mon, 29 Apr 2024 15:25:13 -0500 Subject: [PATCH] added first working version of code --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 3 +++ main.py | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 .DS_Store create mode 100644 .gitignore create mode 100644 main.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d9a693e8267df8994eeb5376a4f39ec3e03a56e5 GIT binary patch literal 6148 zcmeHK!AiqG5S?wSrWBzEg&r5Y7OYl^#Y?F52aM=Jr6#6mFwK^xwMZ%CtUu(J_&v_- zuF_DwiCCF|*|$48FUh`y-3$PT&LrFer~-h4PFN^o^M%no`H~fEq=YE+HTsYS({vcb zDp<_P${^*iM zXG+DvN8b<5qyDs4-8xpu*pHI_NE4#4k11CdQ4*?YM@^D2)m+a^IAy2YtJY?-=3%=o zn~m1IE@$oiMqM5>Tl0C@+1}YbI_*8ggG4;y!YwEm!qXxhv)EVxR)7^)c?InL=~PyJCAp##E}+Vi3K@*0GXsE)L7{bsoE^VG`F*9iBAZ+m=?45iS&(@{I(OE0e sZ_vpoFEjW_!HzzPF_(_w8oD-&OX?uH7BhnwLE|3*Edw{Kz^^Ls4v~vlm;e9( literal 0 HcmV?d00001 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4de579b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +images* +test.py +1.jpg diff --git a/main.py b/main.py new file mode 100644 index 0000000..046a304 --- /dev/null +++ b/main.py @@ -0,0 +1,20 @@ +import cv2 +import pytesseract +import os +directory = 'images' + +# iterate over files in +# that directory +for filename in os.listdir(directory): + f = os.path.join(directory, filename) + # checking if it is a file + if os.path.isfile(f): + image = cv2.imread(f, 0) + thresh = 255 - cv2.threshold(image, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1] + #bottom 2 locations + 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' ) + print(data) + os.rename(f'{f}', f'images/{data}.jpg')