27
27
/* * @file Protonect.cpp Main application file. */
28
28
29
29
#include < iostream>
30
+ #include < cstdlib>
30
31
#include < signal.h>
31
32
32
33
// / [headers]
@@ -112,7 +113,7 @@ int main(int argc, char *argv[])
112
113
std::string program_path (argv[0 ]);
113
114
std::cerr << " Version: " << LIBFREENECT2_VERSION << std::endl;
114
115
std::cerr << " Environment variables: LOGFILE=<protonect.log>" << std::endl;
115
- std::cerr << " Usage: " << program_path << " [gl | cl | cuda | cpu] [<device serial>]" << std::endl;
116
+ std::cerr << " Usage: " << program_path << " [-gpu=<id>] [ gl | cl | cuda | cpu] [<device serial>]" << std::endl;
116
117
std::cerr << " [-noviewer] [-norgb | -nodepth] [-help] [-version]" << std::endl;
117
118
std::cerr << " To pause and unpause: pkill -USR1 Protonect" << std::endl;
118
119
size_t executable_name_idx = program_path.rfind (" Protonect" );
@@ -152,6 +153,7 @@ int main(int argc, char *argv[])
152
153
bool viewer_enabled = true ;
153
154
bool enable_rgb = true ;
154
155
bool enable_depth = true ;
156
+ int deviceId = -1 ;
155
157
156
158
for (int argI = 1 ; argI < argc; ++argI)
157
159
{
@@ -162,6 +164,15 @@ int main(int argc, char *argv[])
162
164
// Just let the initial lines display at the beginning of main
163
165
return 0 ;
164
166
}
167
+ else if (arg.find (" -gpu=" ) == 0 )
168
+ {
169
+ if (pipeline)
170
+ {
171
+ std::cerr << " -gpu must be specified before pipeline argument" << std::endl;
172
+ return -1 ;
173
+ }
174
+ deviceId = atoi (argv[argI] + 5 );
175
+ }
165
176
else if (arg == " cpu" )
166
177
{
167
178
if (!pipeline)
@@ -182,7 +193,7 @@ int main(int argc, char *argv[])
182
193
{
183
194
#ifdef LIBFREENECT2_WITH_OPENCL_SUPPORT
184
195
if (!pipeline)
185
- pipeline = new libfreenect2::OpenCLPacketPipeline ();
196
+ pipeline = new libfreenect2::OpenCLPacketPipeline (deviceId );
186
197
#else
187
198
std::cout << " OpenCL pipeline is not supported!" << std::endl;
188
199
#endif
@@ -191,7 +202,7 @@ int main(int argc, char *argv[])
191
202
{
192
203
#ifdef LIBFREENECT2_WITH_CUDA_SUPPORT
193
204
if (!pipeline)
194
- pipeline = new libfreenect2::CudaPacketPipeline ();
205
+ pipeline = new libfreenect2::CudaPacketPipeline (deviceId );
195
206
#else
196
207
std::cout << " CUDA pipeline is not supported!" << std::endl;
197
208
#endif
0 commit comments