Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pickle
__pycache__
23 changes: 13 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ def main(input_path, output_path, flags):
start = time.time()

name,ext = os.path.splitext(input_path)
name = name.split('/')[-1]

name = os.path.basename(name)
name = os.path.splitext(name)[0]
#name = name.split('/')[-1]

image = cv2.imread(input_path, 1)
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

if not os.path.isdir('tmp'):
os.mkdir('tmp')

if os.path.isfile('tmp/' + name + '_etf.pickle'):
with open('tmp/' + name + '_etf.pickle', 'rb') as file:
if os.path.isfile(os.path.join('tmp',name+'_etf.pickle')):
with open(os.path.join('tmp',name+'_etf.pickle'), 'rb') as file:
etf = pickle.load(file)

print_progress('ETF Horiz',0,1)
Expand All @@ -43,12 +46,12 @@ def main(input_path, output_path, flags):

print ('ETF - ', time2 - time1)

with open('tmp/' + name + '_etf.pickle', 'wb') as file:
with open(os.path.join('tmp',name+'_etf.pickle'), 'wb') as file:
pickle.dump(etf,file)


if os.path.isfile('tmp/' + name + '_edges.pickle'):
with open('tmp/' + name + '_edges.pickle', 'rb') as file:
if os.path.isfile(os.path.join('tmp',name+'_edges.pickle')):
with open(os.path.join('tmp',name+'_edges.pickle'), 'rb') as file:
edges = pickle.load(file)

print_progress('DOG',0,1)
Expand All @@ -64,12 +67,12 @@ def main(input_path, output_path, flags):

print ('FDoG - ', time2 - time1)

with open('tmp/' + name + '_edges.pickle', 'wb') as file:
with open(os.path.join('tmp',name+'_edges.pickle'), 'wb') as file:
pickle.dump(edges,file)


if os.path.isfile('tmp/' + name + '_smooth.pickle'):
with open('tmp/' + name + '_smooth.pickle', 'rb') as file:
if os.path.isfile(os.path.join('tmp',name+'_smooth.pickle')):
with open(os.path.join('tmp',name+'_smooth.pickle'), 'rb') as file:
smoothed_image = pickle.load(file)

print_progress('FBL S',0,1)
Expand All @@ -85,7 +88,7 @@ def main(input_path, output_path, flags):

print ('FBL - ',time2 - time1)

with open('tmp/' + name + '_smooth.pickle', 'wb') as file:
with open(os.path.join('tmp',name+'_smooth.pickle'), 'wb') as file:
pickle.dump(smoothed_image,file)

size = image.shape
Expand Down
22 changes: 12 additions & 10 deletions main_threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ def main(input_path, output_path, flags):

start = time.time()
name,ext = os.path.splitext(input_path)
name = name.split('/')[-1]
name = os.path.basename(name)
name = os.path.splitext(name)[0]
#name = name.split('/')[-1]

image = cv2.imread(input_path, 1)
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

if not os.path.isdir('tmp'):
os.mkdir('tmp')

if os.path.isfile('tmp/' + name + '_etf.pickle'):
with open('tmp/' + name + '_etf.pickle', 'rb') as file:
if os.path.isfile(os.path.join('tmp',name+'_etf.pickle')):
with open(os.path.join('tmp',name+'_etf.pickle'), 'rb') as file:
etf = pickle.load(file)

print_progress('ETF Horiz',0,1)
Expand All @@ -35,12 +37,12 @@ def main(input_path, output_path, flags):

etf = ETF.ETF(gray_image, iterations = 1, mu = 5, type = 0)

with open('tmp/' + name + '_etf.pickle', 'wb') as file:
with open(os.path.join('tmp',name+'_etf.pickle'), 'wb') as file:
pickle.dump(etf,file)

t1_created = False
if os.path.isfile('tmp/' + name + '_edges.pickle'):
with open('tmp/' + name + '_edges.pickle', 'rb') as file:
if os.path.isfile(os.path.join('tmp',name+'_edges.pickle')):
with open(os.path.join('tmp',name+'_edges.pickle'), 'rb') as file:
edges = pickle.load(file)

print_progress('DOG',0,1)
Expand All @@ -54,8 +56,8 @@ def main(input_path, output_path, flags):
t1.start()

t2_created = False
if os.path.isfile('tmp/' + name + '_smooth.pickle'):
with open('tmp/' + name + '_smooth.pickle', 'rb') as file:
if os.path.isfile(os.path.join('tmp',name+'_smooth.pickle')):
with open(os.path.join('tmp',name+'_smooth.pickle'), 'rb') as file:
smoothed_image = pickle.load(file)

print_progress('FBL S',0,1)
Expand All @@ -71,15 +73,15 @@ def main(input_path, output_path, flags):
if t1_created:

t1.join()
with open('tmp/' + name + '_edges.pickle', 'wb') as file:
with open(os.path.join('tmp',name+'_edges.pickle'), 'wb') as file:
pickle.dump(FDoG_threaded.edges,file)

edges = FDoG_threaded.edges

if t2_created:

t2.join()
with open('tmp/' + name + '_smooth.pickle', 'wb') as file:
with open(os.path.join('tmp',name+'_smooth.pickle'), 'wb') as file:
pickle.dump(FBL_threaded.smoothed_image,file)

smoothed_image = FBL_threaded.smoothed_image
Expand Down