diff --git a/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.cpp b/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.cpp index ec423dc..c61223e 100644 --- a/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.cpp +++ b/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.cpp @@ -8,9 +8,8 @@ const bool DRAW_ON_IMG = false; -vector compression_params; DWORD save_image_thread_process(LPVOID param); -bool bFinish = false; + map index_to_algo_type = {{0, algorithm_type_t::HUMAN_SNAPSHOT}, {1, algorithm_type_t::NONMOTOR_VEHICLE_SNAPSHOT}, @@ -29,7 +28,7 @@ save_snapshot_reprocessing::save_snapshot_reprocessing() { callback_ = nullptr; #endif - compression_params.push_back(cv::IMWRITE_JPEG_QUALITY); + compression_params.push_back(cv::IMWRITE_JPEG_QUALITY); compression_params.push_back(30); _snapshot_reprocessing = snapshot_reprocessing::getInstance(); @@ -326,21 +325,28 @@ void save_snapshot_reprocessing::reprocessing_process_face(const OBJ_KEY &obj_ke } } -// 快照保存子线程 依次从缓存队列中取数据 然后保存图片 然后MQ返回结果 DWORD save_image_thread_process(LPVOID param) { save_snapshot_reprocessing *pThreadParam = (save_snapshot_reprocessing *)param; + if (pThreadParam != nullptr){ + pThreadParam->save_image_process(); + } + return 0; +} + +// 快照保存子线程 依次从缓存队列中取数据 然后保存图片 然后MQ返回结果 +void save_snapshot_reprocessing::save_image_process() { while (true) { if (bFinish){ break; } - std::unique_lock l(pThreadParam->waitforsave_image_queue_mutex); - std::unique_lock l_taskid(pThreadParam->waitforchange_taskid_mutex); - if (!pThreadParam->waitforsave_image_queue.empty()) { - SNAPSHOT_IMAGE_UNIT cur_image = pThreadParam->waitforsave_image_queue.front(); - pThreadParam->waitforsave_image_queue.pop(); - if (pThreadParam->task_on_play.find(cur_image.obj_key.video_id) == pThreadParam->task_on_play.end()) { + std::unique_lock l(waitforsave_image_queue_mutex); + std::unique_lock l_taskid(waitforchange_taskid_mutex); + if (!waitforsave_image_queue.empty()) { + SNAPSHOT_IMAGE_UNIT cur_image = waitforsave_image_queue.front(); + waitforsave_image_queue.pop(); + if (task_on_play.find(cur_image.obj_key.video_id) == task_on_play.end()) { LOG_DEBUG("opencv nosave img {}", cur_image.ori_file_name.c_str()); if (cur_image.ori_image.data != nullptr) { delete[] cur_image.ori_image.data; @@ -385,9 +391,9 @@ DWORD save_image_thread_process(LPVOID param) { } #ifdef POST_USE_RABBITMQ - if (pThreadParam->callback_ != nullptr) { + if (callback_ != nullptr) { // LOG_DEBUG("mq publish process 00000000000000000"); - pThreadParam->callback_(cur_image.json_str.c_str()); + callback_(cur_image.json_str.c_str()); // LOG_DEBUG("mq publish process 11111111111111111"); } @@ -410,7 +416,6 @@ DWORD save_image_thread_process(LPVOID param) { std::this_thread::sleep_for(std::chrono::milliseconds(10)); } } - return 0; } void save_snapshot_reprocessing::add_newtask(const string taskid) { diff --git a/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.h b/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.h index a8a2590..1d9de99 100644 --- a/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.h +++ b/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.h @@ -76,6 +76,9 @@ public: ); public: + void save_image_process(); + +private: queue waitforsave_image_queue; mutable std::mutex waitforsave_image_queue_mutex; @@ -84,6 +87,9 @@ public: mutable std::mutex waitforchange_taskid_mutex; std::thread m_save_ss_thread; + bool bFinish = false; + + vector compression_params; #ifdef POST_USE_RABBITMQ callback_t callback_;