-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.py
72 lines (57 loc) · 2.45 KB
/
generate.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os, sys, time, glob
from os import path
import DataSetGeneration.continuous_dataset_generation as DeepCalibDataset
def clearOutputFolder(output_dir):
out_360_image_paths = glob.glob(output_dir+"/*.*")
for imname in out_360_image_paths:
os.remove(imname)
print("delete " + imname)
print("delete " + output_dir)
os.rmdir(output_dir)
# ##############################################################################
def generate(path_to_360_images, output_dir, samples):
starttime = time.process_time()
list_360_image_paths = glob.glob(path_to_360_images)
for impath in list_360_image_paths:
DeepCalibDataset.generateSingleImageProjections(impath, output_dir, samples)
print("elapsed time ", time.process_time() - starttime)
# ##############################################################################
def generateNumImages(path_to_360_images, output_dir, num, samples):
starttime = time.process_time()
list_360_image_paths = glob.glob(path_to_360_images)
for i in range(num):
impath = list_360_image_paths[i]
DeepCalibDataset.generateSingleImageProjections(impath, output_dir, samples)
print("elapsed time ", time.process_time() - starttime)
# ##############################################################################
if __name__ == '__main__':
num_samples_peer_image = int(sys.argv[1])
num_images = int(sys.argv[2])
path_to_360_images = sys.argv[3] + '*.jpg'
output_dir = sys.argv[4]
if len(sys.argv) > 5:
if int(sys.argv[5]) == 1:
clearOutputFolder(output_dir)
if os. path. exists(output_dir):
if len(os.listdir(output_dir)) == 0:
if num_images == -1:
generate(path_to_360_images, output_dir,
num_samples_peer_image)
else:
generateNumImages(path_to_360_images,
output_dir,
num_images,
num_samples_peer_image)
else:
print("use cached data ...")
else:
os.mkdir(output_dir)
if num_images == -1:
generate(path_to_360_images,
output_dir,
num_samples_peer_image)
else:
generateNumImages(path_to_360_images,
output_dir,
num_images,
num_samples_peer_image)