Browse Source

Should work, needs heavy testing

master
Pedro Sá Couto 5 years ago
parent
commit
0b751dc160
  1. BIN
      .DS_Store
  2. 2
      bounding_box.py
  3. 2
      merge_files.sh
  4. 33
      mirror_crop.py
  5. 36
      rotation.py
  6. BIN
      scans/.DS_Store
  7. 4
      workshop_stream.sh

BIN
.DS_Store

Binary file not shown.

2
mask_crop.py → 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)

2
merge_files.sh

@ -4,4 +4,4 @@
cd ocred
pwd
pdfunite *.pdf out.pdf
pdfunite *.pdf ../out.pdf

33
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

36
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

BIN
scans/.DS_Store

Binary file not shown.

4
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

Loading…
Cancel
Save