-
Notifications
You must be signed in to change notification settings - Fork 0
/
loop smart_splitter.py
44 lines (39 loc) · 1.27 KB
/
loop smart_splitter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#from frames_stitcher import frames_stitcher
import os, cv2
import time
from scripts.smart_splitter import smart_splitter
from scripts.write_output import write_output
#log start time
start_time = time.perf_counter()
#add paths
inputPath = ".//input//"
outputPath = ".//output//"
extension = ".png"
#get chapter
list_of_files = os.listdir(inputPath)
print("\n\t\tMachi Image-Stitcher")
print("\nDetected folders in .\input:\n")
print("\t[+] - Input")
print("\t | ")
for files in list_of_files:
print(f"\t └ {files}")
chapter = input(f"\nChoose (enter index) a folder to split or press enter to split all: ")
if chapter != "":
try:
photo = cv2.imread(f"{inputPath}{list_of_files[int(chapter)]}")
split_images = smart_splitter(photo, list_of_files[int(chapter)])
write_output(split_images[0],split_images[1])
except Exception as e:
print(e)
pass
else:
for files in list_of_files:
try:
photo = cv2.imread(f"{inputPath}{files}")
split_images = smart_splitter(photo, files)
write_output(split_images[0],split_images[1])
except Exception as e:
print(e)
pass
print(f"\nProcess completed in {time.perf_counter()-start_time} seconds.")
input('\nPress ENTER to exit')