-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
451 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.48 KB
.../data/results/rubiks_mylagfnc_True_winsearch_True_window_20px_overlap_0pc_padding_0sq.pdf
Binary file not shown.
Binary file added
BIN
+12.9 KB
...data/results/rubiks_mylagfnc_True_winsearch_True_window_20px_overlap_50pc_padding_0sq.pdf
Binary file not shown.
Binary file added
BIN
+150 KB
...data/results/rubiks_mylagfnc_True_winsearch_True_window_20px_overlap_90pc_padding_0sq.pdf
Binary file not shown.
Binary file added
BIN
+133 KB
...data/results/rubiks_mylagfnc_True_winsearch_True_window_20px_overlap_90pc_padding_1sq.pdf
Binary file not shown.
Binary file added
BIN
+128 KB
...data/results/rubiks_mylagfnc_True_winsearch_True_window_20px_overlap_90pc_padding_2sq.pdf
Binary file not shown.
Binary file added
BIN
+23.7 KB
...data/results/rubiks_mylagfnc_True_winsearch_True_window_50px_overlap_90pc_padding_0sq.pdf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from src.functions_2D import * | ||
from PIL import Image | ||
import numpy as np | ||
import time | ||
import logging | ||
from scipy import signal | ||
from scipy import ndimage, misc | ||
import matplotlib.pyplot as plt | ||
import matplotlib.cm as cm | ||
import matplotlib.colors as colors | ||
from scipy.ndimage import gaussian_filter | ||
import numpy.ma as ma | ||
|
||
def main(win=30, | ||
o=0.50, | ||
pad=0, | ||
wss=False, | ||
my_lag=True): | ||
filenames=os.listdir('5_Depth_maps/data/') | ||
jpgs = [x for x in filenames if '.jpg' in x] | ||
file_pairs = [] | ||
|
||
for x in jpgs: | ||
name = x.split('_')[0] | ||
if x.split('_')[1] == 'left.jpg': | ||
file_pairs.append(('5_Depth_maps/data/'+x, '5_Depth_maps/data/'+name+'_right.jpg')) | ||
|
||
ims = ['giraffe', 'block', 'rubiks'] | ||
for k, p in enumerate(file_pairs): | ||
left, right = load_image_pairs(p) | ||
log.debug('image pair loaded') | ||
|
||
try: | ||
# if True: | ||
lags_mapped_to_2D = GetDepthMap(left, | ||
right, | ||
windowsize=win, | ||
overlap=o, | ||
padding=pad, | ||
windowsearch=wss, | ||
use_my_lag_function=my_lag) | ||
|
||
# save file | ||
filename=f'5_Depth_maps/data/results/{ims[k]}_mylagfnc_{my_lag}_window_{int(win)}px_overlap_{int(o*100)}pc_padding_{int(pad)}sq.pdf' | ||
cmap = plt.cm.jet | ||
image = cmap(lags_mapped_to_2D) | ||
plt.imshow(lags_mapped_to_2D) | ||
plt.colorbar() | ||
plt.savefig(filename) | ||
plt.clf() | ||
print(f'output saved to {filename}') | ||
|
||
except: | ||
print(f'error, likely with overlap, try a smaller overlap') | ||
pass | ||
|
||
if __name__ == "__main__": | ||
start = time.time() | ||
main(win=45, | ||
o=0.90, | ||
pad=0, | ||
wss=False, | ||
my_lag=True) | ||
end = time.time() | ||
log.info(f'Time taken: {end-start}s') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
from get_depth import * | ||
import numpy as np | ||
|
||
# I load the functions python -i 5_Depth_maps/parameter_grid_search.py | ||
# then run in GridSearchDepthHyperParameters in the command line. | ||
|
||
def GridSearchDepthHyperParameters(win_search_space=np.unique(np.concatenate((np.linspace(10, 25, 16), np.linspace(5, 50, 10)), axis=0)), | ||
overlap_search_space=np.unique(np.concatenate((np.linspace(0, 0.9, 10), np.linspace(0.7, 0.99, 30)), axis=0)), | ||
padding_search_space=np.linspace(0, 2, 3), | ||
window_search_strategy_search_space=[True, False], | ||
mylagfunc_search_space=[True, False]): | ||
""" Performed parameter search for depth maps. | ||
Args: | ||
win_search_space (1D np array): window search size in pixels. Defaults to np.linspace(5,50,10). | ||
overlap_search_space (1D np array): overlap of windows. Defaults to np.linspace(0.7,0.99,30). | ||
padding_search_space (1D np array): pad window to increase search space. Defaults to np.linspace(0, 2, 3) | ||
window_search_strategy_search_space (list): search in a widow or along a row. Defaults to [True, False]. | ||
mylagfunc_search_space (list): uses my 2Dlag function or scipy's signal.correlate. Defaults to [True, False]. | ||
""" | ||
filenames=os.listdir('5_Depth_maps/data/') | ||
jpgs = [x for x in filenames if '.jpg' in x] | ||
file_pairs = [] | ||
|
||
for x in jpgs: | ||
name = x.split('_')[0] | ||
if x.split('_')[1] == 'left.jpg': | ||
file_pairs.append(('5_Depth_maps/data/'+x, '5_Depth_maps/data/'+name+'_right.jpg')) | ||
|
||
ims = ['giraffe', 'block', 'rubiks'] | ||
for k, p in enumerate(file_pairs): | ||
left, right = load_image_pairs(p) | ||
log.debug('image pair loaded') | ||
|
||
for wss in window_search_strategy_search_space: | ||
for b in mylagfunc_search_space: | ||
for win in win_search_space: | ||
for o in overlap_search_space: | ||
for pad in padding_search_space: | ||
try: | ||
lags_mapped_to_2D = GetDepthMap(left, | ||
right, | ||
windowsize=int(win), | ||
overlap=o, | ||
padding=int(pad), | ||
windowsearch=wss, | ||
use_my_lag_function=b) | ||
filename=f'5_Depth_maps/data/research/{ims[k]}_mylagfnc_{b}_winsearch_{wss}_window_{int(win)}px_overlap_{int(o*100)}pc_padding_{int(pad)}sq.pdf' | ||
cmap = plt.cm.jet | ||
image = cmap(lags_mapped_to_2D) | ||
plt.imshow(lags_mapped_to_2D) | ||
plt.colorbar() | ||
# plt.show() | ||
plt.savefig(filename) | ||
plt.clf() | ||
print(f'saved window {int(win)}, overlap {int(o*100)} and padding {int(pad)} with my lag function {b} and window search {wss}') | ||
except: | ||
pass |
Binary file not shown.
Oops, something went wrong.