-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract_orientation_patches.py
68 lines (54 loc) · 2.2 KB
/
extract_orientation_patches.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
# -*- coding: utf-8 -*-
"""
.. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de>
"""
import argparse as ap
from nicr_rgb_d_orientation_data_set import SETS, SIZES, SIZE_SMALL
from nicr_rgb_d_orientation_data_set import load_set
def _parse_args():
"""Parse command-line arguments"""
parser = ap.ArgumentParser(
description='Simple script for extracting patches from '
'NICR-RGB-D-Orientation-Data-Set without further '
'preprocessing',
formatter_class=ap.RawTextHelpFormatter
)
parser.add_argument('-d', '--dataset_basepath',
type=str,
default='./datasets/NICR-RGB-D-Orientation-Data-Set',
help=("Path to downloaded dataset, default: "
"'./datasets/NICR-RGB-D-Orientation-Data-Set'"))
parser.add_argument('-s', '--size',
type=str,
choices=SIZES,
default=SIZE_SMALL,
help=(f"Image size to extract the patches for. One "
f"of :{SIZES}, default: {SIZE_SMALL}"))
parser.add_argument('-sn', '--set_names',
type=str,
nargs='+',
default=SETS,
help=("Sets to extract the patches for. One of :"
f"{SETS}"))
parser.add_argument('-v', '--verbose',
action='store_true',
default=False,
help='Enable verbose output')
# return parsed args
return parser.parse_args()
def main():
# parse args
args = _parse_args()
# extract patches
for set_name in args.set_names:
if args.verbose:
print(f"Processing {set_name} set ...")
# load dataset
dataset = load_set(dataset_basepath=args.dataset_basepath,
set_name=set_name,
default_size=args.size)
# extract all patches
dataset.extract_all_patches(size=None,
with_progressbar=args.verbose)
if __name__ == '__main__':
main()