Add reverse workspace filter option

This commit is contained in:
gqc
2026-07-08 19:16:02 +08:00
parent 041c830bfb
commit cb078492bc
6 changed files with 215 additions and 44 deletions
+39 -27
View File
@@ -96,8 +96,10 @@ static const char *help_info[100] = {
"camera id",
"type id",
"upload port",
"workspace, use comma spearated coordinate, like 0,1,2,3"
"threshold, like 0.7, default is 0.6"};
"workspace, use comma spearated coordinate, like 0,1,2,3",
"threshold, like 0.7, default is 0.6",
"time period, like 08:00:00-18:00:00",
"reverse workspace filter, upload targets outside -w"};
static struct option long_options[] = {
{"server", required_argument, NULL, 's'},
@@ -106,10 +108,11 @@ static struct option long_options[] = {
{"camera-id", required_argument, NULL, 'c'},
{"type-id", required_argument, NULL, 't'},
{"upload-port", required_argument, NULL, 'p'},
{"workspace", required_argument, NULL, 'w'},
{"threshold", required_argument, NULL, 'r'},
{"time-period", required_argument, NULL, 'P'},
{0, 0, 0}};
{"workspace", required_argument, NULL, 'w'},
{"threshold", required_argument, NULL, 'r'},
{"time-period", required_argument, NULL, 'P'},
{"reverse-workspace", no_argument, NULL, 'R'},
{0, 0, 0}};
void print_usage(char *cmd)
{
@@ -152,14 +155,15 @@ void parse_options(int argc, char **argv)
bool polygon_inited = false;
char *workspace_points = (char*)"";
float *points;
int thresh;
conf_threshold = DEFAULT_CONF_THRESHOLD;
char *cmd = argv[0];
int ok;
int thresh;
conf_threshold = DEFAULT_CONF_THRESHOLD;
ReverseWorkspace = false;
char *cmd = argv[0];
int ok;
while (1)
{
int option_index = 0;
c = getopt_long_only(argc, argv, "es:m:w:c:t:p:r:P:", long_options, &option_index);
c = getopt_long_only(argc, argv, "es:m:w:c:t:p:r:P:R", long_options, &option_index);
if (c == -1)
{
break;
@@ -202,22 +206,30 @@ void parse_options(int argc, char **argv)
}
conf_threshold = (float)thresh / 100.0;
break;
case 'P':
ok = get_all_time_period_from_arguments(optarg);
if (ok != 0) {
printf("failed to parse time period\n");
exit(-1);
}
break;
default:
print_usage(cmd);
exit(-1);
}
}
if (!polygon_inited) {
init_polygon(NULL, 0);
}
case 'P':
ok = get_all_time_period_from_arguments(optarg);
if (ok != 0) {
printf("failed to parse time period\n");
exit(-1);
}
break;
case 'R':
ReverseWorkspace = true;
break;
default:
print_usage(cmd);
exit(-1);
}
}
if (ReverseWorkspace && !polygon_inited) {
printf("-R/--reverse-workspace must be used with -w/--workspace\n");
exit(-1);
}
if (!polygon_inited) {
init_polygon(NULL, 0);
}
}
int main(int argc, char *argv[])