Skip to content

Commit 664ff3c

Browse files
hanyazouxlz
authored andcommitted
Protonect: Add '-frames' option
1 parent 4e1bc69 commit 664ff3c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

examples/Protonect.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ int main(int argc, char *argv[])
115115
std::cerr << "Environment variables: LOGFILE=<protonect.log>" << std::endl;
116116
std::cerr << "Usage: " << program_path << " [-gpu=<id>] [gl | cl | cuda | cpu] [<device serial>]" << std::endl;
117117
std::cerr << " [-noviewer] [-norgb | -nodepth] [-help] [-version]" << std::endl;
118+
std::cerr << " [-frames <number of frames to process>]" << std::endl;
118119
std::cerr << "To pause and unpause: pkill -USR1 Protonect" << std::endl;
119120
size_t executable_name_idx = program_path.rfind("Protonect");
120121

@@ -154,6 +155,7 @@ int main(int argc, char *argv[])
154155
bool enable_rgb = true;
155156
bool enable_depth = true;
156157
int deviceId = -1;
158+
size_t framemax = -1;
157159

158160
for(int argI = 1; argI < argc; ++argI)
159161
{
@@ -223,6 +225,15 @@ int main(int argc, char *argv[])
223225
{
224226
enable_depth = false;
225227
}
228+
else if(arg == "-frames")
229+
{
230+
++argI;
231+
framemax = strtol(argv[argI], NULL, 0);
232+
if (framemax == 0) {
233+
std::cerr << "invalid frame count '" << argv[argI] << "'" << std::endl;
234+
return -1;
235+
}
236+
}
226237
else
227238
{
228239
std::cout << "Unknown argument: " << arg << std::endl;
@@ -317,7 +328,7 @@ int main(int argc, char *argv[])
317328
#endif
318329

319330
/// [loop start]
320-
while(!protonect_shutdown)
331+
while(!protonect_shutdown && (framemax == (size_t)-1 || framecount < framemax))
321332
{
322333
listener.waitForNewFrame(frames);
323334
libfreenect2::Frame *rgb = frames[libfreenect2::Frame::Color];

0 commit comments

Comments
 (0)