From 23907c4441eae23f1277ac63c0f0f7043f20d058 Mon Sep 17 00:00:00 2001 From: cmhu <2657262686@qq.com> Date: Tue, 9 Apr 2024 10:38:09 +0800 Subject: [PATCH] 添加28181测试 --- src/demo/demo.cpp | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 151 insertions(+), 2 deletions(-) diff --git a/src/demo/demo.cpp b/src/demo/demo.cpp index 846e90b..8ea4b8e 100755 --- a/src/demo/demo.cpp +++ b/src/demo/demo.cpp @@ -1064,6 +1064,82 @@ string createTask(void *handle, std::vector algor_vec, int gi, return task_id_str; } + +string createTask_dvpp28181(void *handle, std::vector algor_vec, int gi, bool bFlag = true){ + task_param tparam; + + switch(gi){ + case 0: + tparam.ipc_url = "34020000001310004065"; + break; + case 1: + tparam.ipc_url = "34020000001310000001"; + break; + case 2: + tparam.ipc_url = "34020000001310000201"; + break; + default: + tparam.ipc_url = "34020000001310004065"; + break; + } + + tparam.algor_counts = algor_vec.size(); + tparam.dec_type = 3; + tparam.protocal = 0; + + if (bFlag){ + nTaskId = gi; + } + + std::string task_id_str = "test_task_id_" + std::to_string(nTaskId); + tparam.task_id = task_id_str.c_str(); + + nTaskId++; + + tparam.algor_config_params = new algor_config_param[tparam.algor_counts]; + + for (size_t idx = 0; idx < algor_vec.size(); ++idx) + set_task_params(tparam, idx, algor_vec.at(idx)); + + const int result_code = add_task(handle, tparam); + if (result_code != 0) + printf("[Error]: "); + printf("--- task_id: %s result code: %d\n", tparam.task_id, result_code); + + + // 释放参数 + for (size_t idx = 0; idx < algor_vec.size(); ++idx) { + if(tparam.algor_config_params[idx].algor_type == algorithm_type_t::VIDEO_TIMING_SNAPSHOT) { + algor_config_param_road_work* algor_param = (algor_config_param_road_work*)tparam.algor_config_params[idx].algor_init_config_param->algor_param; + delete algor_param; + algor_basic_config_param_t* basic_param = (algor_basic_config_param_t*)tparam.algor_config_params[idx].algor_init_config_param->basic_param; + delete basic_param; + + algor_init_config_param_t* config_param = tparam.algor_config_params[idx].algor_init_config_param; + delete config_param; + } else if(tparam.algor_config_params[idx].algor_type == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND) { + algor_config_param_manned_incident* algor_param = (algor_config_param_manned_incident*)tparam.algor_config_params[idx].algor_init_config_param->algor_param; + delete algor_param; + algor_basic_config_param_t* basic_param = (algor_basic_config_param_t*)tparam.algor_config_params[idx].algor_init_config_param->basic_param; + delete basic_param; + + algor_init_config_param_t* config_param = tparam.algor_config_params[idx].algor_init_config_param; + delete config_param; + }else if(tparam.algor_config_params[idx].algor_type == algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND) { + algor_config_param_manned_incident* algor_param = (algor_config_param_manned_incident*)tparam.algor_config_params[idx].algor_init_config_param->algor_param; + delete algor_param; + algor_basic_config_param_t* basic_param = (algor_basic_config_param_t*)tparam.algor_config_params[idx].algor_init_config_param->basic_param; + delete basic_param; + + algor_init_config_param_t* config_param = tparam.algor_config_params[idx].algor_init_config_param; + delete config_param; + } + } + delete[] tparam.algor_config_params; + + return task_id_str; +} + void test_snapshot(void *handle){ task_param tparam; 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){ tsl_aiplatform_release(&handle); } +void test_dvpp28181(int gpuID) { + tsl_aiplatform_param vptParam; + vptParam.gpuid = gpuID; + vptParam.trt_serialize_file = ""; + vptParam.models_dir = "."; + + vptParam.log_days = 1; + vptParam.log_level = AI_LOG_LEVEL_TRACE; + // vptParam.log_level = AI_LOG_LEVEL_DEBUG; + vptParam.log_mem = 64 * 1024 * 1024; // 64MB. + vptParam.log_path = "logs/main.log"; + vptParam.vpt_thred = 0.45; + vptParam.rblock_thred = 0.4; + + void *handle; + int flag = tsl_aiplatform_init(&handle, vptParam); + if (0 != flag) { + printf("Init Failed! Error Code: %d\n", flag); + return; + } else { + printf("Init Success\n"); + } + +#ifdef POST_USE_RABBITMQ +init_mq_conn(handle); +#endif // #ifdef POST_USE_RABBITMQ + + std::vector 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, + 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 + , 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}; + + + std::vector 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, + 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, + 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, + algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND, algorithm_type_t::VEHICLE_NOTDECELERATION}; + // std::vector 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, + // algorithm_type_t::NONMOTOR_VEHICLE_REFIT, algorithm_type_t::PERSON_RUNNING_REDLIGHTS, algorithm_type_t::NONMOTOR_RUNNING_REDLIGHTS}; + std::vector algor_vec3 = {algorithm_type_t::PERSON_CROSS, algorithm_type_t::NONMOTOR_WRONGDIRECTION, algorithm_type_t::VEHICLE_WRONGDIRECTION, algorithm_type_t::VEHICLE_NOTGIVEWAY, + algorithm_type_t::VEHICLE_SOLIDLINETURNAROUND}; + + + +char ch = 'a'; +while (ch != 'q') { + ch = getchar(); + switch (ch) + { + case '0': + createTask_dvpp28181(handle, algor_vec2, 0, false); + break; + case '1': + createTask_dvpp28181(handle, algor_vec2, 1, false); + break; + case '2': + createTask_dvpp28181(handle, algor_vec2, 2, false); + break; + case 'c': + close_all_task(handle); + break; + default: + break; + } + +} + + // finish_task(handle, (char*)task_id.data(), 0); + + // finish_task(handle, (char*)task_id1.data(), 0); + + tsl_aiplatform_release(&handle); +} + int main(int argc, char *argv[]) { printf("new test\n"); @@ -1215,12 +1364,12 @@ int main(int argc, char *argv[]) { // int repeat_num = atoi(argv[3]); // int gpuID = atoi(argv[4]); - test_gpu(0); + // test_gpu(0); // test_gpu(1); // test_gpu(2); // test_gpu(3); - while (getchar() != 'q'); + test_dvpp28181(0); printf("Done.\n"); -- libgit2 0.21.4