diff --git a/.DS_Store b/.DS_Store index 59fbf23..a1d8211 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/mask_crop.py b/bounding_box.py similarity index 94% rename from mask_crop.py rename to bounding_box.py index 4b9f2ea..0f4c481 100644 --- a/mask_crop.py +++ b/bounding_box.py @@ -5,7 +5,7 @@ d = 1 while True: try: - output = ('cropped/page%d.jpg'%d) + output = ('bounding_box/input%d.jpg'%d) # Load image, convert to grayscale, and find edges image = cv2.imread('rotated/input%d.jpg'%d) diff --git a/merge_files.sh b/merge_files.sh index 004c02c..57b5cbb 100755 --- a/merge_files.sh +++ b/merge_files.sh @@ -4,4 +4,4 @@ cd ocred pwd -pdfunite *.pdf out.pdf +pdfunite *.pdf ../out.pdf diff --git a/mirror_crop.py b/mirror_crop.py new file mode 100644 index 0000000..71a02d0 --- /dev/null +++ b/mirror_crop.py @@ -0,0 +1,33 @@ +from PIL import Image +from PIL import ImageOps +import time + + +i = 1 + +while True: + + page = Image.open("bounding_box/input%i.jpg"%i) + + if i % 2 == 0: + #check where the for loop is + print("cropping even") + + # left, up, right, bottom + border = (0, 0, 165, 0) + finalpage = ImageOps.crop(page, border) + finalpage.save('cropped/page%i.jpg'%i) + + else: + #check where the for loop is + print("cropping odd") + + # left, up, right, bottom + border = (165, 0, 0, 0) + finalpage = ImageOps.crop(page, border) + finalpage.save('cropped/page%i.jpg'%i) + + time.sleep(1) + print("variable i: ", i) + + i+=1 diff --git a/rotation.py b/rotation.py new file mode 100644 index 0000000..e6f4a18 --- /dev/null +++ b/rotation.py @@ -0,0 +1,36 @@ +from PIL import Image +import time + +i = 1 + +while True: + + page = Image.open("split/input%i.jpg"%i) + + if i % 2 == 0: + #check where the for loop is + print("trying even") + + #rotate image by 90 degrees + angle = 90 + out = page.rotate(angle, expand=True) + out.save('rotated/input%i.jpg'%i) + print('This is an even page number') + + time.sleep(2) + print("variable i: ", i) + + else: + #check where the for loop is + print("trying odd") + + #rotate image by 90 degrees + angle = 270 + out = page.rotate(angle, expand=True) + out.save('rotated/input%i.jpg'%i) + print('This is an odd page number') + + time.sleep(1) + print("variable i: ", i) + + i+=1 diff --git a/scans/.DS_Store b/scans/.DS_Store new file mode 100644 index 0000000..3ffcfeb Binary files /dev/null and b/scans/.DS_Store differ diff --git a/workshop_stream.sh b/workshop_stream.sh index 187732f..557800c 100755 --- a/workshop_stream.sh +++ b/workshop_stream.sh @@ -1,10 +1,12 @@ mkdir split mkdir rotated mkdir ocred +mkdir bounding_box mkdir cropped ./merge_scans.sh python3 burstpdf.py python3 rotation.py -python3 mask_crop.py +python3 bounding_box.py +python3 mirror_crop.py python3 tesseract_ocr.py ./merge_files.sh