Commit 23907c4441eae23f1277ac63c0f0f7043f20d058

Authored by Hu Chunming
1 parent ddde99a1

添加28181测试

Showing 1 changed file with 151 additions and 2 deletions
src/demo/demo.cpp
... ... @@ -1064,6 +1064,82 @@ string createTask(void *handle, std::vector<algorithm_type_t> algor_vec, int gi,
1064 1064 return task_id_str;
1065 1065 }
1066 1066  
  1067 +
  1068 +string createTask_dvpp28181(void *handle, std::vector<algorithm_type_t> algor_vec, int gi, bool bFlag = true){
  1069 + task_param tparam;
  1070 +
  1071 + switch(gi){
  1072 + case 0:
  1073 + tparam.ipc_url = "34020000001310004065";
  1074 + break;
  1075 + case 1:
  1076 + tparam.ipc_url = "34020000001310000001";
  1077 + break;
  1078 + case 2:
  1079 + tparam.ipc_url = "34020000001310000201";
  1080 + break;
  1081 + default:
  1082 + tparam.ipc_url = "34020000001310004065";
  1083 + break;
  1084 + }
  1085 +
  1086 + tparam.algor_counts = algor_vec.size();
  1087 + tparam.dec_type = 3;
  1088 + tparam.protocal = 0;
  1089 +
  1090 + if (bFlag){
  1091 + nTaskId = gi;
  1092 + }
  1093 +
  1094 + std::string task_id_str = "test_task_id_" + std::to_string(nTaskId);
  1095 + tparam.task_id = task_id_str.c_str();
  1096 +
  1097 + nTaskId++;
  1098 +
  1099 + tparam.algor_config_params = new algor_config_param[tparam.algor_counts];
  1100 +
  1101 + for (size_t idx = 0; idx < algor_vec.size(); ++idx)
  1102 + set_task_params(tparam, idx, algor_vec.at(idx));
  1103 +
  1104 + const int result_code = add_task(handle, tparam);
  1105 + if (result_code != 0)
  1106 + printf("[Error]: ");
  1107 + printf("--- task_id: %s result code: %d\n", tparam.task_id, result_code);
  1108 +
  1109 +
  1110 + // 释放参数
  1111 + for (size_t idx = 0; idx < algor_vec.size(); ++idx) {
  1112 + if(tparam.algor_config_params[idx].algor_type == algorithm_type_t::VIDEO_TIMING_SNAPSHOT) {
  1113 + algor_config_param_road_work* algor_param = (algor_config_param_road_work*)tparam.algor_config_params[idx].algor_init_config_param->algor_param;
  1114 + delete algor_param;
  1115 + algor_basic_config_param_t* basic_param = (algor_basic_config_param_t*)tparam.algor_config_params[idx].algor_init_config_param->basic_param;
  1116 + delete basic_param;
  1117 +
  1118 + algor_init_config_param_t* config_param = tparam.algor_config_params[idx].algor_init_config_param;
  1119 + delete config_param;
  1120 + } else if(tparam.algor_config_params[idx].algor_type == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND) {
  1121 + algor_config_param_manned_incident* algor_param = (algor_config_param_manned_incident*)tparam.algor_config_params[idx].algor_init_config_param->algor_param;
  1122 + delete algor_param;
  1123 + algor_basic_config_param_t* basic_param = (algor_basic_config_param_t*)tparam.algor_config_params[idx].algor_init_config_param->basic_param;
  1124 + delete basic_param;
  1125 +
  1126 + algor_init_config_param_t* config_param = tparam.algor_config_params[idx].algor_init_config_param;
  1127 + delete config_param;
  1128 + }else if(tparam.algor_config_params[idx].algor_type == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND) {
  1129 + algor_config_param_manned_incident* algor_param = (algor_config_param_manned_incident*)tparam.algor_config_params[idx].algor_init_config_param->algor_param;
  1130 + delete algor_param;
  1131 + algor_basic_config_param_t* basic_param = (algor_basic_config_param_t*)tparam.algor_config_params[idx].algor_init_config_param->basic_param;
  1132 + delete basic_param;
  1133 +
  1134 + algor_init_config_param_t* config_param = tparam.algor_config_params[idx].algor_init_config_param;
  1135 + delete config_param;
  1136 + }
  1137 + }
  1138 + delete[] tparam.algor_config_params;
  1139 +
  1140 + return task_id_str;
  1141 +}
  1142 +
1067 1143 void test_snapshot(void *handle){
1068 1144 task_param tparam;
1069 1145 tparam.ipc_url = "rtsp://admin:ad123456@192.168.60.165:554/cam/realmonitor?channel=1&subtype=0";
... ... @@ -1201,6 +1277,79 @@ void test_gpu(int gpuID){
1201 1277 tsl_aiplatform_release(&handle);
1202 1278 }
1203 1279  
  1280 +void test_dvpp28181(int gpuID) {
  1281 + tsl_aiplatform_param vptParam;
  1282 + vptParam.gpuid = gpuID;
  1283 + vptParam.trt_serialize_file = "";
  1284 + vptParam.models_dir = ".";
  1285 +
  1286 + vptParam.log_days = 1;
  1287 + vptParam.log_level = AI_LOG_LEVEL_TRACE;
  1288 + // vptParam.log_level = AI_LOG_LEVEL_DEBUG;
  1289 + vptParam.log_mem = 64 * 1024 * 1024; // 64MB.
  1290 + vptParam.log_path = "logs/main.log";
  1291 + vptParam.vpt_thred = 0.45;
  1292 + vptParam.rblock_thred = 0.4;
  1293 +
  1294 + void *handle;
  1295 + int flag = tsl_aiplatform_init(&handle, vptParam);
  1296 + if (0 != flag) {
  1297 + printf("Init Failed! Error Code: %d\n", flag);
  1298 + return;
  1299 + } else {
  1300 + printf("Init Success\n");
  1301 + }
  1302 +
  1303 +#ifdef POST_USE_RABBITMQ
  1304 +init_mq_conn(handle);
  1305 +#endif // #ifdef POST_USE_RABBITMQ
  1306 +
  1307 + std::vector<algorithm_type_t> algor_vec = {algorithm_type_t::FACE_SNAPSHOT, algorithm_type_t::HUMAN_SNAPSHOT,algorithm_type_t::ROAD_WORK_DET, algorithm_type_t::PEDESTRIAN_RETROGRADE, algorithm_type_t::VEHICLE_RETROGRADE,
  1308 + algorithm_type_t::PEDESTRIAN_TRESPASS, algorithm_type_t::VEHICLE_TRESPASS, algorithm_type_t::VEHICLE_SNAPSHOT, algorithm_type_t::NONMOTOR_VEHICLE_SNAPSHOT, algorithm_type_t::VIDEO_TIMING_SNAPSHOT
  1309 + , algorithm_type_t::VIDEO_SNAPSHOT, algorithm_type_t::NONMOTOR_VEHICLE_NOHELMET, algorithm_type_t::NONMOTOR_VEHICLE_OVERMAN, algorithm_type_t::TRICYCLE_MANNED, algorithm_type_t::TRUCK_MANNED};
  1310 +
  1311 +
  1312 + std::vector<algorithm_type_t> algor_vec2 = {algorithm_type_t::NONMOTOR_VEHICLE_NOHELMET, algorithm_type_t::NONMOTOR_VEHICLE_OVERMAN, algorithm_type_t::TRICYCLE_MANNED, algorithm_type_t::TRUCK_MANNED, algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE,
  1313 + algorithm_type_t::NONMOTOR_VEHICLE_REFIT, algorithm_type_t::PERSON_RUNNING_REDLIGHTS, algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS, algorithm_type_t::PERSON_IN_VEHICLELANE, algorithm_type_t::NONMOTOR_IN_VEHICLELANE,
  1314 + algorithm_type_t::NONMOTOR_CEOSSPARKLINE, algorithm_type_t::PERSON_CROSS, algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, algorithm_type_t::VEHICLE_NOTGIVEWAY,
  1315 + algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND, algorithm_type_t::VEHICLE_NOTDECELERATION};
  1316 + // std::vector<algorithm_type_t> algor_vec3 = {algorithm_type_t::NONMOTOR_VEHICLE_NOHELMET, algorithm_type_t::NONMOTOR_VEHICLE_OVERMAN, algorithm_type_t::TRICYCLE_MANNED, algorithm_type_t::TRUCK_MANNED, algorithm_type_t::NONMOTOR_VEHICLE_USEPHONE,
  1317 + // algorithm_type_t::NONMOTOR_VEHICLE_REFIT, algorithm_type_t::PERSON_RUNNING_REDLIGHTS, algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS};
  1318 + std::vector<algorithm_type_t> algor_vec3 = {algorithm_type_t::PERSON_CROSS, algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, algorithm_type_t::VEHICLE_NOTGIVEWAY,
  1319 + algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND};
  1320 +
  1321 +
  1322 +
  1323 +char ch = 'a';
  1324 +while (ch != 'q') {
  1325 + ch = getchar();
  1326 + switch (ch)
  1327 + {
  1328 + case '0':
  1329 + createTask_dvpp28181(handle, algor_vec2, 0, false);
  1330 + break;
  1331 + case '1':
  1332 + createTask_dvpp28181(handle, algor_vec2, 1, false);
  1333 + break;
  1334 + case '2':
  1335 + createTask_dvpp28181(handle, algor_vec2, 2, false);
  1336 + break;
  1337 + case 'c':
  1338 + close_all_task(handle);
  1339 + break;
  1340 + default:
  1341 + break;
  1342 + }
  1343 +
  1344 +}
  1345 +
  1346 + // finish_task(handle, (char*)task_id.data(), 0);
  1347 +
  1348 + // finish_task(handle, (char*)task_id1.data(), 0);
  1349 +
  1350 + tsl_aiplatform_release(&handle);
  1351 +}
  1352 +
1204 1353 int main(int argc, char *argv[]) {
1205 1354 printf("new test\n");
1206 1355  
... ... @@ -1215,12 +1364,12 @@ int main(int argc, char *argv[]) {
1215 1364 // int repeat_num = atoi(argv[3]);
1216 1365 // int gpuID = atoi(argv[4]);
1217 1366  
1218   - test_gpu(0);
  1367 + // test_gpu(0);
1219 1368 // test_gpu(1);
1220 1369 // test_gpu(2);
1221 1370 // test_gpu(3);
1222 1371  
1223   - while (getchar() != 'q');
  1372 + test_dvpp28181(0);
1224 1373  
1225 1374 printf("Done.\n");
1226 1375  
... ...