|
28 | 28 |
|
29 | 29 | #include <json/json.h> |
30 | 30 | #include <k4a/k4a.h> |
| 31 | +#include <map> |
31 | 32 | #include <set> |
32 | 33 | #include <string> |
33 | 34 | #include <unordered_map> |
|
38 | 39 | namespace open3d { |
39 | 40 | namespace io { |
40 | 41 |
|
41 | | -static std::unordered_map<k4a_image_format_t, std::string> |
42 | | - k4a_image_format_t_to_string({ |
43 | | - {K4A_IMAGE_FORMAT_COLOR_MJPG, "K4A_IMAGE_FORMAT_COLOR_MJPG"}, |
44 | | - {K4A_IMAGE_FORMAT_COLOR_NV12, "K4A_IMAGE_FORMAT_COLOR_NV12"}, |
45 | | - {K4A_IMAGE_FORMAT_COLOR_YUY2, "K4A_IMAGE_FORMAT_COLOR_YUY2"}, |
46 | | - {K4A_IMAGE_FORMAT_COLOR_BGRA32, |
47 | | - "K4A_IMAGE_FORMAT_COLOR_BGRA32"}, |
48 | | - {K4A_IMAGE_FORMAT_DEPTH16, "K4A_IMAGE_FORMAT_DEPTH16"}, |
49 | | - {K4A_IMAGE_FORMAT_IR16, "K4A_IMAGE_FORMAT_IR16"}, |
50 | | - {K4A_IMAGE_FORMAT_CUSTOM, "K4A_IMAGE_FORMAT_CUSTOM"}, |
51 | | - }); |
52 | | - |
53 | | -static std::unordered_map<k4a_color_resolution_t, std::string> |
54 | | - k4a_color_resolution_t_to_string({ |
| 42 | +static std::map<k4a_image_format_t, std::string> k4a_image_format_t_to_string{ |
| 43 | + {K4A_IMAGE_FORMAT_COLOR_MJPG, "K4A_IMAGE_FORMAT_COLOR_MJPG"}, |
| 44 | + {K4A_IMAGE_FORMAT_COLOR_NV12, "K4A_IMAGE_FORMAT_COLOR_NV12"}, |
| 45 | + {K4A_IMAGE_FORMAT_COLOR_YUY2, "K4A_IMAGE_FORMAT_COLOR_YUY2"}, |
| 46 | + {K4A_IMAGE_FORMAT_COLOR_BGRA32, "K4A_IMAGE_FORMAT_COLOR_BGRA32"}, |
| 47 | + {K4A_IMAGE_FORMAT_DEPTH16, "K4A_IMAGE_FORMAT_DEPTH16"}, |
| 48 | + {K4A_IMAGE_FORMAT_IR16, "K4A_IMAGE_FORMAT_IR16"}, |
| 49 | + {K4A_IMAGE_FORMAT_CUSTOM, "K4A_IMAGE_FORMAT_CUSTOM"}, |
| 50 | +}; |
| 51 | + |
| 52 | +static std::map<k4a_color_resolution_t, std::string> |
| 53 | + k4a_color_resolution_t_to_string{ |
55 | 54 | {K4A_COLOR_RESOLUTION_OFF, "K4A_COLOR_RESOLUTION_OFF"}, |
56 | 55 | {K4A_COLOR_RESOLUTION_720P, "K4A_COLOR_RESOLUTION_720P"}, |
57 | 56 | {K4A_COLOR_RESOLUTION_1080P, "K4A_COLOR_RESOLUTION_1080P"}, |
58 | 57 | {K4A_COLOR_RESOLUTION_1440P, "K4A_COLOR_RESOLUTION_1440P"}, |
59 | 58 | {K4A_COLOR_RESOLUTION_1536P, "K4A_COLOR_RESOLUTION_1536P"}, |
60 | 59 | {K4A_COLOR_RESOLUTION_2160P, "K4A_COLOR_RESOLUTION_2160P"}, |
61 | 60 | {K4A_COLOR_RESOLUTION_3072P, "K4A_COLOR_RESOLUTION_3072P"}, |
62 | | - }); |
63 | | - |
64 | | -static std::unordered_map<k4a_depth_mode_t, std::string> |
65 | | - k4a_depth_mode_t_to_string({ |
66 | | - {K4A_DEPTH_MODE_OFF, "K4A_DEPTH_MODE_OFF"}, |
67 | | - {K4A_DEPTH_MODE_NFOV_2X2BINNED, |
68 | | - "K4A_DEPTH_MODE_NFOV_2X2BINNED"}, |
69 | | - {K4A_DEPTH_MODE_NFOV_UNBINNED, "K4A_DEPTH_MODE_NFOV_UNBINNED"}, |
70 | | - {K4A_DEPTH_MODE_WFOV_2X2BINNED, |
71 | | - "K4A_DEPTH_MODE_WFOV_2X2BINNED"}, |
72 | | - {K4A_DEPTH_MODE_WFOV_UNBINNED, "K4A_DEPTH_MODE_WFOV_UNBINNED"}, |
73 | | - {K4A_DEPTH_MODE_PASSIVE_IR, "K4A_DEPTH_MODE_PASSIVE_IR"}, |
74 | | - }); |
75 | | - |
76 | | -static std::unordered_map<k4a_fps_t, std::string> k4a_fps_t_to_string({ |
| 61 | + }; |
| 62 | + |
| 63 | +static std::map<k4a_depth_mode_t, std::string> k4a_depth_mode_t_to_string{ |
| 64 | + {K4A_DEPTH_MODE_OFF, "K4A_DEPTH_MODE_OFF"}, |
| 65 | + {K4A_DEPTH_MODE_NFOV_2X2BINNED, "K4A_DEPTH_MODE_NFOV_2X2BINNED"}, |
| 66 | + {K4A_DEPTH_MODE_NFOV_UNBINNED, "K4A_DEPTH_MODE_NFOV_UNBINNED"}, |
| 67 | + {K4A_DEPTH_MODE_WFOV_2X2BINNED, "K4A_DEPTH_MODE_WFOV_2X2BINNED"}, |
| 68 | + {K4A_DEPTH_MODE_WFOV_UNBINNED, "K4A_DEPTH_MODE_WFOV_UNBINNED"}, |
| 69 | + {K4A_DEPTH_MODE_PASSIVE_IR, "K4A_DEPTH_MODE_PASSIVE_IR"}, |
| 70 | +}; |
| 71 | + |
| 72 | +static std::map<k4a_fps_t, std::string> k4a_fps_t_to_string{ |
77 | 73 | {K4A_FRAMES_PER_SECOND_5, "K4A_FRAMES_PER_SECOND_5"}, |
78 | 74 | {K4A_FRAMES_PER_SECOND_15, "K4A_FRAMES_PER_SECOND_15"}, |
79 | 75 | {K4A_FRAMES_PER_SECOND_30, "K4A_FRAMES_PER_SECOND_30"}, |
80 | | -}); |
| 76 | +}; |
81 | 77 |
|
82 | | -static std::unordered_map<k4a_wired_sync_mode_t, std::string> |
83 | | - k4a_wired_sync_mode_t_to_string({ |
| 78 | +static std::map<k4a_wired_sync_mode_t, std::string> |
| 79 | + k4a_wired_sync_mode_t_to_string{ |
84 | 80 | {K4A_WIRED_SYNC_MODE_STANDALONE, |
85 | 81 | "K4A_WIRED_SYNC_MODE_STANDALONE"}, |
86 | 82 | {K4A_WIRED_SYNC_MODE_MASTER, "K4A_WIRED_SYNC_MODE_MASTER"}, |
87 | 83 | {K4A_WIRED_SYNC_MODE_SUBORDINATE, |
88 | 84 | "K4A_WIRED_SYNC_MODE_SUBORDINATE"}, |
89 | | - }); |
90 | | - |
91 | | -static std::unordered_map<std::string, k4a_image_format_t> |
92 | | - string_to_k4a_image_format_t({ |
93 | | - {"K4A_IMAGE_FORMAT_COLOR_MJPG", K4A_IMAGE_FORMAT_COLOR_MJPG}, |
94 | | - {"K4A_IMAGE_FORMAT_COLOR_NV12", K4A_IMAGE_FORMAT_COLOR_NV12}, |
95 | | - {"K4A_IMAGE_FORMAT_COLOR_YUY2", K4A_IMAGE_FORMAT_COLOR_YUY2}, |
96 | | - {"K4A_IMAGE_FORMAT_COLOR_BGRA32", |
97 | | - K4A_IMAGE_FORMAT_COLOR_BGRA32}, |
98 | | - {"K4A_IMAGE_FORMAT_DEPTH16", K4A_IMAGE_FORMAT_DEPTH16}, |
99 | | - {"K4A_IMAGE_FORMAT_IR16", K4A_IMAGE_FORMAT_IR16}, |
100 | | - {"K4A_IMAGE_FORMAT_CUSTOM", K4A_IMAGE_FORMAT_CUSTOM}, |
101 | | - }); |
102 | | - |
103 | | -static std::unordered_map<std::string, k4a_color_resolution_t> |
104 | | - string_to_k4a_color_resolution_t({ |
| 85 | + }; |
| 86 | + |
| 87 | +static std::map<std::string, k4a_image_format_t> string_to_k4a_image_format_t({ |
| 88 | + {"K4A_IMAGE_FORMAT_COLOR_MJPG", K4A_IMAGE_FORMAT_COLOR_MJPG}, |
| 89 | + {"K4A_IMAGE_FORMAT_COLOR_NV12", K4A_IMAGE_FORMAT_COLOR_NV12}, |
| 90 | + {"K4A_IMAGE_FORMAT_COLOR_YUY2", K4A_IMAGE_FORMAT_COLOR_YUY2}, |
| 91 | + {"K4A_IMAGE_FORMAT_COLOR_BGRA32", K4A_IMAGE_FORMAT_COLOR_BGRA32}, |
| 92 | + {"K4A_IMAGE_FORMAT_DEPTH16", K4A_IMAGE_FORMAT_DEPTH16}, |
| 93 | + {"K4A_IMAGE_FORMAT_IR16", K4A_IMAGE_FORMAT_IR16}, |
| 94 | + {"K4A_IMAGE_FORMAT_CUSTOM", K4A_IMAGE_FORMAT_CUSTOM}, |
| 95 | +}); |
| 96 | + |
| 97 | +static std::map<std::string, k4a_color_resolution_t> |
| 98 | + string_to_k4a_color_resolution_t{ |
105 | 99 | {"K4A_COLOR_RESOLUTION_OFF", K4A_COLOR_RESOLUTION_OFF}, |
106 | 100 | {"K4A_COLOR_RESOLUTION_720P", K4A_COLOR_RESOLUTION_720P}, |
107 | 101 | {"K4A_COLOR_RESOLUTION_1080P", K4A_COLOR_RESOLUTION_1080P}, |
108 | 102 | {"K4A_COLOR_RESOLUTION_1440P", K4A_COLOR_RESOLUTION_1440P}, |
109 | 103 | {"K4A_COLOR_RESOLUTION_1536P", K4A_COLOR_RESOLUTION_1536P}, |
110 | 104 | {"K4A_COLOR_RESOLUTION_2160P", K4A_COLOR_RESOLUTION_2160P}, |
111 | 105 | {"K4A_COLOR_RESOLUTION_3072P", K4A_COLOR_RESOLUTION_3072P}, |
112 | | - }); |
113 | | - |
114 | | -static std::unordered_map<std::string, k4a_depth_mode_t> |
115 | | - string_to_k4a_depth_mode_t({ |
116 | | - {"K4A_DEPTH_MODE_OFF", K4A_DEPTH_MODE_OFF}, |
117 | | - {"K4A_DEPTH_MODE_NFOV_2X2BINNED", |
118 | | - K4A_DEPTH_MODE_NFOV_2X2BINNED}, |
119 | | - {"K4A_DEPTH_MODE_NFOV_UNBINNED", K4A_DEPTH_MODE_NFOV_UNBINNED}, |
120 | | - {"K4A_DEPTH_MODE_WFOV_2X2BINNED", |
121 | | - K4A_DEPTH_MODE_WFOV_2X2BINNED}, |
122 | | - {"K4A_DEPTH_MODE_WFOV_UNBINNED", K4A_DEPTH_MODE_WFOV_UNBINNED}, |
123 | | - {"K4A_DEPTH_MODE_PASSIVE_IR", K4A_DEPTH_MODE_PASSIVE_IR}, |
124 | | - }); |
125 | | - |
126 | | -static std::unordered_map<std::string, k4a_fps_t> string_to_k4a_fps_t({ |
| 106 | + }; |
| 107 | + |
| 108 | +static std::map<std::string, k4a_depth_mode_t> string_to_k4a_depth_mode_t{ |
| 109 | + {"K4A_DEPTH_MODE_OFF", K4A_DEPTH_MODE_OFF}, |
| 110 | + {"K4A_DEPTH_MODE_NFOV_2X2BINNED", K4A_DEPTH_MODE_NFOV_2X2BINNED}, |
| 111 | + {"K4A_DEPTH_MODE_NFOV_UNBINNED", K4A_DEPTH_MODE_NFOV_UNBINNED}, |
| 112 | + {"K4A_DEPTH_MODE_WFOV_2X2BINNED", K4A_DEPTH_MODE_WFOV_2X2BINNED}, |
| 113 | + {"K4A_DEPTH_MODE_WFOV_UNBINNED", K4A_DEPTH_MODE_WFOV_UNBINNED}, |
| 114 | + {"K4A_DEPTH_MODE_PASSIVE_IR", K4A_DEPTH_MODE_PASSIVE_IR}, |
| 115 | +}; |
| 116 | + |
| 117 | +static std::map<std::string, k4a_fps_t> string_to_k4a_fps_t{ |
127 | 118 | {"K4A_FRAMES_PER_SECOND_5", K4A_FRAMES_PER_SECOND_5}, |
128 | 119 | {"K4A_FRAMES_PER_SECOND_15", K4A_FRAMES_PER_SECOND_15}, |
129 | 120 | {"K4A_FRAMES_PER_SECOND_30", K4A_FRAMES_PER_SECOND_30}, |
130 | | -}); |
| 121 | +}; |
131 | 122 |
|
132 | | -static std::unordered_map<std::string, k4a_wired_sync_mode_t> |
133 | | - string_to_k4a_wired_sync_mode_t({ |
| 123 | +static std::map<std::string, k4a_wired_sync_mode_t> |
| 124 | + string_to_k4a_wired_sync_mode_t{ |
134 | 125 | {"K4A_WIRED_SYNC_MODE_STANDALONE", |
135 | 126 | K4A_WIRED_SYNC_MODE_STANDALONE}, |
136 | 127 | {"K4A_WIRED_SYNC_MODE_MASTER", K4A_WIRED_SYNC_MODE_MASTER}, |
137 | 128 | {"K4A_WIRED_SYNC_MODE_SUBORDINATE", |
138 | 129 | K4A_WIRED_SYNC_MODE_SUBORDINATE}, |
139 | | - }); |
| 130 | + }; |
140 | 131 |
|
141 | 132 | static std::unordered_map<std::string, std::string> standard_config{ |
142 | 133 | {"color_format", "K4A_IMAGE_FORMAT_COLOR_MJPG"}, |
|
0 commit comments