Commit 571e8ac81b9989bce65d7cff69d5e2f35cb1a7c5
1 parent
dd314366
完成轨迹定时抓拍
Showing
3 changed files
with
27 additions
and
21 deletions
src/ai_platform/MultiSourceProcess.cpp
@@ -449,7 +449,7 @@ int CMultiSourceProcess::algorthim_vpt(vector<DeviceMemory*> vec_gpuMem){ | @@ -449,7 +449,7 @@ int CMultiSourceProcess::algorthim_vpt(vector<DeviceMemory*> vec_gpuMem){ | ||
449 | #else | 449 | #else |
450 | algorithm_vehicle_relult(vec_vptMem, vptResult, deleteObjectID); | 450 | algorithm_vehicle_relult(vec_vptMem, vptResult, deleteObjectID); |
451 | 451 | ||
452 | - // send_locus_finished_msg(vpt_interest_task_id, deleteObjectID); | 452 | + send_locus_finished_msg(vpt_interest_task_id, deleteObjectID); |
453 | #endif | 453 | #endif |
454 | 454 | ||
455 | if(vptResult.size() > 0){ | 455 | if(vptResult.size() > 0){ |
@@ -509,13 +509,18 @@ int CMultiSourceProcess::algorithm_vehicle_relult(vector<DeviceMemory*> vec_devM | @@ -509,13 +509,18 @@ int CMultiSourceProcess::algorithm_vehicle_relult(vector<DeviceMemory*> vec_devM | ||
509 | strcpy(new_obj_ss_info.video_image_path, fpath_origin.c_str()); | 509 | strcpy(new_obj_ss_info.video_image_path, fpath_origin.c_str()); |
510 | strcpy(new_obj_ss_info.snapshot_image_path, fpath_roi.c_str()); | 510 | strcpy(new_obj_ss_info.snapshot_image_path, fpath_roi.c_str()); |
511 | new_obj_ss_info.nFinished = 0; | 511 | new_obj_ss_info.nFinished = 0; |
512 | - string json_str = "1111";//helpers::gen_json::gen_multi_obj_json(algorithm_type_t::VEHICLE_SNAPSHOT, new_obj_ss_info); | 512 | + string json_str = helpers::gen_json::gen_multi_obj_json(algorithm_type_t::VEHICLE_SNAPSHOT, new_obj_ss_info); |
513 | 513 | ||
514 | ImgSaveInfo save_info; | 514 | ImgSaveInfo save_info; |
515 | save_info.file_path = fpath_roi; | 515 | save_info.file_path = fpath_roi; |
516 | save_info.img_info = vec_obj_info_list[i]; | 516 | save_info.img_info = vec_obj_info_list[i]; |
517 | save_info.json_str = json_str; | 517 | save_info.json_str = json_str; |
518 | m_save_snapshot_reprocessing->reprocessing_process_wo_locus_async(save_info); | 518 | m_save_snapshot_reprocessing->reprocessing_process_wo_locus_async(save_info); |
519 | + | ||
520 | + OBJ_KEY obj_key{task_id, obj.object_id}; | ||
521 | + // 保存有轨迹的object记录,轨迹结束时需要发消息 | ||
522 | + std::lock_guard<std::mutex> l(m_total_mutex); | ||
523 | + m_total_snapshot_info_multi_object.insert(obj_key); | ||
519 | } | 524 | } |
520 | 525 | ||
521 | vec_obj_info_list.clear(); | 526 | vec_obj_info_list.clear(); |
@@ -535,23 +540,24 @@ void CMultiSourceProcess::send_locus_finished_msg(vector<string>& vpt_interest_t | @@ -535,23 +540,24 @@ void CMultiSourceProcess::send_locus_finished_msg(vector<string>& vpt_interest_t | ||
535 | OBJ_KEY obj_key = {task_id, j}; | 540 | OBJ_KEY obj_key = {task_id, j}; |
536 | 541 | ||
537 | auto task_param_ptr = m_task_param_manager->get_task_algor_param(task_id); | 542 | auto task_param_ptr = m_task_param_manager->get_task_algor_param(task_id); |
538 | - auto task_other_param_ptr = m_task_param_manager->get_task_other_param(task_id); | ||
539 | 543 | ||
540 | // 该路任务开启了抓拍功能 开始抓拍保存;若未开启抓拍,清空显存资源 | 544 | // 该路任务开启了抓拍功能 开始抓拍保存;若未开启抓拍,清空显存资源 |
541 | - // if (task_param_ptr->vehicle_algors.find(algorithm_type_t::VEHICLE_SNAPSHOT) != task_param_ptr->vehicle_algors.end()) { | ||
542 | - // std::lock_guard<std::mutex> l(m_total_mutex); | ||
543 | - // if (m_total_snapshot_info_multi_object.find(obj_key) != m_total_snapshot_info_multi_object.end()) { | ||
544 | - // video_object_snapshot new_obj_ss_info; | ||
545 | - // new_obj_ss_info.object_id = j; | ||
546 | - // new_obj_ss_info.nFinished = 1; | ||
547 | - // strcpy(new_obj_ss_info.task_id, task_id.c_str()); | ||
548 | - // string json_str = helpers::gen_json::gen_multi_obj_json(algorithm_type_t::VEHICLE_SNAPSHOT, new_obj_ss_info); | ||
549 | - // // 通知结束的轨迹 | ||
550 | - // m_save_snapshot_reprocessing->reprocessing_finish_locus_async(obj_key,json_str); | ||
551 | - | ||
552 | - // m_total_snapshot_info_multi_object.erase(obj_key); | ||
553 | - // } | ||
554 | - // } | 545 | + if (task_param_ptr->vehicle_algors.find(algorithm_type_t::VEHICLE_SNAPSHOT) != task_param_ptr->vehicle_algors.end()) { |
546 | + std::lock_guard<std::mutex> l(m_total_mutex); | ||
547 | + if (m_total_snapshot_info_multi_object.find(obj_key) != m_total_snapshot_info_multi_object.end()) { | ||
548 | + video_object_snapshot new_obj_ss_info; | ||
549 | + new_obj_ss_info.object_id = j; | ||
550 | + new_obj_ss_info.nFinished = 1; | ||
551 | + strcpy(new_obj_ss_info.task_id, task_id.c_str()); | ||
552 | + string json_str = helpers::gen_json::gen_multi_obj_json(algorithm_type_t::VEHICLE_SNAPSHOT, new_obj_ss_info); | ||
553 | + // 通知结束的轨迹 | ||
554 | + ImgSaveInfo save_info; | ||
555 | + save_info.json_str = json_str; | ||
556 | + m_save_snapshot_reprocessing->reprocessing_process_wo_locus_async(save_info); | ||
557 | + | ||
558 | + m_total_snapshot_info_multi_object.erase(obj_key); | ||
559 | + } | ||
560 | + } | ||
555 | } | 561 | } |
556 | } | 562 | } |
557 | } | 563 | } |
558 | \ No newline at end of file | 564 | \ No newline at end of file |
src/ai_platform/MultiSourceProcess.h
@@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
12 | #include <list> | 12 | #include <list> |
13 | #include <vector> | 13 | #include <vector> |
14 | #include <deque> | 14 | #include <deque> |
15 | - | 15 | +#include <set> |
16 | 16 | ||
17 | 17 | ||
18 | using namespace std; | 18 | using namespace std; |
@@ -75,6 +75,9 @@ private: | @@ -75,6 +75,9 @@ private: | ||
75 | 75 | ||
76 | int m_batch_size{1}; | 76 | int m_batch_size{1}; |
77 | 77 | ||
78 | + set<OBJ_KEY> m_total_snapshot_info_multi_object; | ||
79 | + mutex m_total_mutex; | ||
80 | + | ||
78 | #ifdef POST_USE_RABBITMQ | 81 | #ifdef POST_USE_RABBITMQ |
79 | mq::Manager *mq_manager_{nullptr}; | 82 | mq::Manager *mq_manager_{nullptr}; |
80 | #endif | 83 | #endif |
src/reprocessing_module/save_snapshot_reprocessing.cpp
@@ -67,9 +67,6 @@ void save_snapshot_reprocessing::set_callback(callback_t cb) { | @@ -67,9 +67,6 @@ void save_snapshot_reprocessing::set_callback(callback_t cb) { | ||
67 | 67 | ||
68 | void save_snapshot_reprocessing::reprocessing_process_wo_locus_async(ImgSaveInfo saveInfo){ | 68 | void save_snapshot_reprocessing::reprocessing_process_wo_locus_async(ImgSaveInfo saveInfo){ |
69 | 69 | ||
70 | - // dvpp_img_release(saveInfo.img_info); | ||
71 | - // return; | ||
72 | - | ||
73 | while(!bFinish){ | 70 | while(!bFinish){ |
74 | waitforsave_img_queue_mutex.lock(); | 71 | waitforsave_img_queue_mutex.lock(); |
75 | if(waitforsave_img_queue.size() > 100){ | 72 | if(waitforsave_img_queue.size() > 100){ |