23 #include <plugins/openni/utils/setup.h>
24 #include <config/config.h>
41 unsigned int &width,
unsigned int &height)
44 std::string cfg_resolution = config->
get_string(
"/plugins/openni/resolution");
46 XnResolution res = XN_RES_VGA;
48 if (cfg_resolution ==
"QQVGA") {
50 }
else if (cfg_resolution ==
"CGA") {
52 }
else if (cfg_resolution ==
"QVGA") {
54 }
else if (cfg_resolution ==
"VGA") {
56 }
else if (cfg_resolution ==
"SVGA") {
58 }
else if (cfg_resolution ==
"XGA") {
60 }
else if (cfg_resolution ==
"720P") {
62 }
else if (cfg_resolution ==
"SXGA") {
64 }
else if (cfg_resolution ==
"UXGA") {
66 }
else if (cfg_resolution ==
"1080P") {
69 throw Exception(
"get_resolution(): Unknown resolution '%s'",
70 cfg_resolution.c_str());
73 xn::Resolution resolution(res);
74 width = resolution.GetXResolution();
75 height = resolution.GetYResolution();
87 setup_map_generator(xn::MapGenerator &generator,
90 unsigned int width = 0, height = 0;
91 get_resolution(config, width, height);
92 unsigned int cfg_fps = config->
get_uint(
"/plugins/openni/fps");
94 XnMapOutputMode output_mode;
95 output_mode.nXRes = width;
96 output_mode.nYRes = height;
97 output_mode.nFPS = cfg_fps;
99 if ((st = generator.SetMapOutputMode(output_mode)) != XN_STATUS_OK) {
100 throw Exception(
"OpenNI: failed to set map output mode: %s",
101 xnGetStatusString(st));
114 setup_alternate_viewpoint(xn::Generator &gen, xn::Generator &target)
116 if (gen.GetAlternativeViewPointCap().IsViewPointAs(target)) {
121 if (! gen.GetAlternativeViewPointCap().IsViewPointSupported(target)) {
122 throw Exception(
"Alternate viewpoint '%s' is not supported by %s",
123 target.GetName(), gen.GetName());
126 XnStatus status = gen.GetAlternativeViewPointCap().SetViewPoint(target);
128 if (status != XN_STATUS_OK) {
129 throw Exception(
"Setting alternate viewpoint '%s' by %s failed: %s",
130 target.GetName(), gen.GetName(), xnGetStatusString(status));
140 setup_synchronization(xn::Generator &gen, xn::Generator &target)
142 if (gen.GetFrameSyncCap().IsFrameSyncedWith(target)) {
146 if (! gen.IsCapabilitySupported(XN_CAPABILITY_FRAME_SYNC)) {
147 throw Exception(
"Generator '%s' does not support frame synchronization",
151 if (! gen.GetFrameSyncCap().CanFrameSyncWith(target)) {
152 throw Exception(
"Generator '%s' cannot synchronize with '%s'",
153 gen.GetName(), target.GetName());
156 XnStatus status = gen.GetFrameSyncCap().FrameSyncWith(target);
158 if (status != XN_STATUS_OK) {
159 throw Exception(
"Setting synchronization of '%s' with '%s' failed: %s",
160 target.GetName(), gen.GetName(), xnGetStatusString(status));
virtual unsigned int get_uint(const char *path)=0
Get value from configuration which is of type unsigned int.
Interface for configuration handling.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.