Compare commits
19 Commits
Author | SHA1 | Date |
---|---|---|
Kabooshki | 1418f3954b | |
Kabooshki | e0fe811463 | |
Kabooshki | 37082b6f3a | |
Kabooshki | a54b43e1f5 | |
Kabooshki | b03b1aaf14 | |
Kabooshki | 81f331b77e | |
Kabooshki | 801277ce2b | |
Kabooshki | 9aaeb28ffc | |
Kabooshki | 1040e754e5 | |
Kabooshki | 3a558db188 | |
Kabooshki | cc23e1df33 | |
Kabooshki | cf8af5ab22 | |
Kabooshki | d7d4bf51e0 | |
Kabooshki | e986b8dd00 | |
Kabooshki | f22510d186 | |
Kabooshki | 84c4122d5f | |
Kabooshki | d371bd0492 | |
Kabooshki | b284314192 | |
Kabooshki | 23bda32298 |
|
@ -1,3 +1,7 @@
|
|||
images*
|
||||
test.py
|
||||
1.jpg
|
||||
test-files.tbkpf
|
||||
".DS_Store"
|
||||
.DS_Store
|
||||
compile*
|
|
@ -0,0 +1,30 @@
|
|||
import cv2
|
||||
import pytesseract
|
||||
import os
|
||||
import numpy
|
||||
directory = 'images'
|
||||
|
||||
# iterate over files in
|
||||
# that directory
|
||||
pattern = 'review' # Replace with your target substring
|
||||
matching_files = [f for f in os.listdir(directory) if pattern in f]
|
||||
|
||||
for files in os.listdir(directory):
|
||||
if files.__contains__(pattern):
|
||||
f = os.path.join(directory, files)
|
||||
print(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])
|
||||
cv2.imshow('Review', ROI)
|
||||
cv2.waitKey(1)
|
||||
manpage = input("please input the page number")
|
||||
if os.path.isfile(f'images/{manpage}.jpg') == True:
|
||||
rng = numpy.random.default_rng().random()
|
||||
os.rename (f'images/{manpage}.jpg', f'images/{manpage}.review-{rng}.jpg')
|
||||
os.rename(f'{f}', f'images/{manpage}.jpg')
|
||||
elif os.path.isfile(f'images/{manpage}.jpg') == False:
|
||||
os.rename(f'{f}', f'images/{manpage}.jpg')
|
26
main.py
26
main.py
|
@ -1,9 +1,9 @@
|
|||
import cv2
|
||||
import pytesseract
|
||||
import os
|
||||
import numpy
|
||||
directory = 'images'
|
||||
|
||||
k = 1
|
||||
|
||||
# iterate over files in
|
||||
# that directory
|
||||
for filename in os.listdir(directory):
|
||||
|
@ -20,9 +20,21 @@ for filename in os.listdir(directory):
|
|||
print(data)
|
||||
if os.path.isfile(f'images/{data}.jpg') == False:
|
||||
os.rename(f'{f}', f'images/{data}.jpg')
|
||||
else:
|
||||
cv2.imshow(ROI)
|
||||
cv2.waitKey(50)
|
||||
os.rename(f'{f}', f'images/{data}.{k}.jpg')
|
||||
k = k + 1
|
||||
elif os.path.isfile(f'images/{data}.jpg') == True:
|
||||
cv2.imshow(data, ROI)
|
||||
cv2.waitKey(1)
|
||||
manpage = input("please input the number on the page (if the title is correct, enter nothing)")
|
||||
#check if the new name already exists
|
||||
if manpage == "\n":
|
||||
rng = numpy.random.default_rng().random()
|
||||
os.rename (f'images/{data}.jpg', f'images/{data}.review-{rng}.jpg')
|
||||
os.rename(f'{f}', f'images/{data}.jpg')
|
||||
elif manpage != "\n":
|
||||
if os.path.isfile(f'images/{manpage}.jpg') == True:
|
||||
rng = numpy.random.default_rng().random()
|
||||
os.rename (f'images/{manpage}.jpg', f'images/{manpage}.review-{rng}.jpg')
|
||||
os.rename(f'{f}', f'images/{manpage}.jpg')
|
||||
elif os.path.isfile(f'images/{manpage}.jpg') == False:
|
||||
os.rename(f'{f}', f'images/{manpage}.jpg')
|
||||
cv2.destroyAllWindows()
|
||||
cv2.destroyAllWindows()
|
||||
|
|
Loading…
Reference in New Issue