diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..315e996 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pickle +__pycache__ \ No newline at end of file diff --git a/main.py b/main.py index c0b6aac..0f1303c 100644 --- a/main.py +++ b/main.py @@ -18,7 +18,10 @@ 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) @@ -26,8 +29,8 @@ def main(input_path, output_path, flags): 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) @@ -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) @@ -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) @@ -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 diff --git a/main_threaded.py b/main_threaded.py index d2c853c..dc47ab0 100644 --- a/main_threaded.py +++ b/main_threaded.py @@ -14,7 +14,9 @@ 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) @@ -22,8 +24,8 @@ def main(input_path, output_path, flags): 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) @@ -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) @@ -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) @@ -71,7 +73,7 @@ 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 @@ -79,7 +81,7 @@ def main(input_path, output_path, flags): 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