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:
Sultan Khan
2026-11-15 12:48:20 +05:30
committed by GitHub
parent b6185cb365
commit be7eede9c5

View File

@@ -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;