diff --git a/samples/cpp/application_trace.cpp b/samples/cpp/application_trace.cpp index 3ad06a4ccd..52cf79fa1b 100644 --- a/samples/cpp/application_trace.cpp +++ b/samples/cpp/application_trace.cpp @@ -28,7 +28,7 @@ int main(int argc, char** argv) cv::CommandLineParser parser(argc, argv, "{help h ? | | help message}" - "{n | 100 | number of frames to process }" + "{n | 100 | number of frames to process (0 for unlimited) }" "{@video | 0 | video filename or cameraID }" ); if (parser.has("help")) @@ -59,6 +59,11 @@ int main(int argc, char** argv) } int N = parser.get("n"); + if (N < 0) + { + cerr << "Error: Number of frames to process must be a non-negative integer." << endl; + return -1; + } if (nframes > 0 && N > nframes) N = nframes;