Yes, you are right, so I revised it early
// new code 2025.3.21
int i=0;
for (LineCrossingInfo & lc:lc_vec) {
if (i == 0) {
lc.operate_on_class[0] = 0;
} else if (i == 1) {
lc.operate_on_class[1] = 1;
} else if (i == 2) {
lc.operate_on_class[2] = 2;
} else if (i == 3) {
lc.operate_on_class[3] = 6;
} else if (i == 4) {
lc.operate_on_class[4] = 7;
}else if (i == 5) {
lc.operate_on_class[5] = 8;
}
i++;
}
//--new code
But then it doesn’t compile
sudo make
g++ -c -o nvdsanalytics_property_parser.o -fPIC -std=c++11 -DDS_VERSION=\"6.3.0\" -I ../../includes -I ../../libs/nvds_analytics -DNDEBUG -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/orc-0.4 -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/aarch64-linux-gnu/glib-2.0/include nvdsanalytics_property_parser.cpp
nvdsanalytics_property_parser.cpp: In function ‘gboolean nvdsanalytics_parse_linecrossing_group(GstNvDsAnalytics*, gchar*, GKeyFile*, gchar*, guint64)’:
nvdsanalytics_property_parser.cpp:571:1: error: jump to label ‘done’
571 | done:
| ^~~~
nvdsanalytics_property_parser.cpp:41:10: note: from here
41 | goto done; \
| ^~~~
nvdsanalytics_property_parser.cpp:526:5: note: in expansion of macro ‘PARSE_ERROR’
526 | PARSE_ERROR ("%s not specified in group '%s'",
| ^~~~~~~~~~~
nvdsanalytics_property_parser.cpp:538:5: note: crosses initialization of ‘int i’
538 | int i=0;
| ^
nvdsanalytics_property_parser.cpp:571:1: error: jump to label ‘done’
571 | done:
| ^~~~
nvdsanalytics_property_parser.cpp:41:10: note: from here
41 | goto done; \
| ^~~~
nvdsanalytics_property_parser.cpp:58:7: note: in expansion of macro ‘PARSE_ERROR’
58 | PARSE_ERROR ("%s %s", errvalue.c_str(), error->message); \
| ^~~~~~~~~~~
nvdsanalytics_property_parser.cpp:425:7: note: in expansion of macro ‘CHECK_ERROR’
425 | CHECK_ERROR (error, group);
| ^~~~~~~~~~~
nvdsanalytics_property_parser.cpp:538:5: note: crosses initialization of ‘int i’
538 | int i=0;
| ^
nvdsanalytics_property_parser.cpp:571:1: error: jump to label ‘done’
571 | done:
| ^~~~
nvdsanalytics_property_parser.cpp:41:10: note: from here
41 | goto done; \
| ^~~~
nvdsanalytics_property_parser.cpp:58:7: note: in expansion of macro ‘PARSE_ERROR’
58 | PARSE_ERROR ("%s %s", errvalue.c_str(), error->message); \
| ^~~~~~~~~~~
nvdsanalytics_property_parser.cpp:420:3: note: in expansion of macro ‘CHECK_ERROR’
420 | CHECK_ERROR (error, group);
| ^~~~~~~~~~~
nvdsanalytics_property_parser.cpp:538:5: note: crosses initialization of ‘int i’
538 | int i=0;
| ^
make: *** [Makefile:52: nvdsanalytics_property_parser.o] Error 1
Finally I relocated the initialization:
enum::eMode eMd = eMode::loose;
std::unordered_map < int, StreamInfo > *stream_analytics_info =
(nvdsanalytics->stream_analytics_info);
lc_info.stream_id = stream_id;
// new code 2025.3.21
int i = 0; // ✅ Move the variable definition to the top of the function
//--new code
keys = g_key_file_get_keys (key_file, group, nullptr, &error);
CHECK_ERROR (error, group);
It compiles successfully, but the end result is not what I wanted
[line-crossing-stream-0]
enable=1
line-crossing-CarEntry=566;611;428;914;258;637;843;629
line-crossing-PersonEntry=566;611;428;914;202;686;849;679
line-crossing-MotorcycleEntry=566;611;428;914;159;740;855;731
class-id=0;1;2
extended=0
mode=balanced
After a long time of observation, I found out
‘CarEntry’ counts Cars, Pedestrians and Motorcycles quantity
‘PersonEntry’ counts the number of pedestrians and motorcycles
‘MotorcycleEntry’ counts the number of pedestrians and motorcycles
Why Is This?