mirror of
https://github.com/opencv/opencv.git
synced 2026-11-17 06:47:47 -06:00
samples: add error check for invalid frame count in application_trace (#30801)
* samples: add error check for invalid frame count in application_trace * samples: reject only negative frame counts * samples: clarify frame count messages in application_trace
This commit is contained in:
@@ -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<int>("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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user