English
File size: 1,845 Bytes
26225c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from collections.abc import Iterable


__all__ = [
    'POINT_FEATURES', 'SEGMENT_BASE_FEATURES', 'SUBEDGE_FEATURES',
    'ON_THE_FLY_HORIZONTAL_FEATURES', 'ON_THE_FLY_VERTICAL_FEATURES',
    'sanitize_keys']


POINT_FEATURES = [
    'rgb',
    'hsv',
    'lab',
    'density',
    'linearity',
    'planarity',
    'scattering',
    'verticality',
    'elevation',
    'normal',
    'length',
    'surface',
    'volume',
    'curvature',
    'intensity',
    'pos_room']

SEGMENT_BASE_FEATURES = [
    'linearity',
    'planarity',
    'scattering',
    'verticality',
    'curvature',
    'log_length',
    'log_surface',
    'log_volume',
    'normal',
    'log_size']

SUBEDGE_FEATURES = [
    'mean_off',
    'std_off',
    'mean_dist']

ON_THE_FLY_HORIZONTAL_FEATURES = [
    'mean_off',
    'std_off',
    'mean_dist',
    'angle_source',
    'angle_target',
    'centroid_dir',
    'centroid_dist',
    'normal_angle',
    'log_length',
    'log_surface',
    'log_volume',
    'log_size']

ON_THE_FLY_VERTICAL_FEATURES = [
    'centroid_dir',
    'centroid_dist',
    'normal_angle',
    'log_length',
    'log_surface',
    'log_volume',
    'log_size']


def sanitize_keys(keys, default=[]):
    """Sanitize an iterable of string key into a sorted list of unique
    keys. This is necessary for consistently hashing key list arguments
    of some transforms.
    """
    # Convert to list of keys
    if isinstance(keys, str):
        out = [keys]
    elif isinstance(keys, Iterable):
        out = list(keys)
    else:
        out = list(default)

    assert all(isinstance(x, str) for x in out), \
        f"Input 'keys' must be a string or an iterable of strings, but some " \
        f"non-string elements were found in '{keys}'"

    # Remove duplicates and sort elements
    out = tuple(sorted(list(set(out))))

    return out