Commit 4a2a28155605bdef7c663f4ff11f17d565bae05f
1 parent
ea385417
代码优化
Showing
3 changed files
with
29 additions
and
10 deletions
tsl_aiplatform/ai_platform/MultiSourceProcess.cpp
@@ -9,8 +9,6 @@ | @@ -9,8 +9,6 @@ | ||
9 | 9 | ||
10 | #include "authority.h" | 10 | #include "authority.h" |
11 | 11 | ||
12 | -#include "NvJpegEncoder.hpp" | ||
13 | - | ||
14 | #ifdef AUTHORIZATION | 12 | #ifdef AUTHORIZATION |
15 | #include <boost/thread.hpp> | 13 | #include <boost/thread.hpp> |
16 | #ifdef _MSC_VER | 14 | #ifdef _MSC_VER |
@@ -270,7 +268,7 @@ int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam) { | @@ -270,7 +268,7 @@ int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam) { | ||
270 | return ret; | 268 | return ret; |
271 | } | 269 | } |
272 | 270 | ||
273 | -bool CMultiSourceProcess::AddTask(task_param _cur_task_param){ | 271 | +int CMultiSourceProcess::AddTask(task_param _cur_task_param){ |
274 | 272 | ||
275 | FFNvDecoderManager* pDecManager = FFNvDecoderManager::getInstance(); | 273 | FFNvDecoderManager* pDecManager = FFNvDecoderManager::getInstance(); |
276 | 274 | ||
@@ -286,7 +284,7 @@ bool CMultiSourceProcess::AddTask(task_param _cur_task_param){ | @@ -286,7 +284,7 @@ bool CMultiSourceProcess::AddTask(task_param _cur_task_param){ | ||
286 | FFNvDecoder* dec = pDecManager->createDecoder(config); | 284 | FFNvDecoder* dec = pDecManager->createDecoder(config); |
287 | if (!dec) | 285 | if (!dec) |
288 | { | 286 | { |
289 | - return false; | 287 | + return -1; |
290 | } | 288 | } |
291 | 289 | ||
292 | decode_cbk_userdata* userPtr = new decode_cbk_userdata; | 290 | decode_cbk_userdata* userPtr = new decode_cbk_userdata; |
@@ -335,6 +333,8 @@ bool CMultiSourceProcess::AddTask(task_param _cur_task_param){ | @@ -335,6 +333,8 @@ bool CMultiSourceProcess::AddTask(task_param _cur_task_param){ | ||
335 | // 所有参数都准备好之后再启动解码 | 333 | // 所有参数都准备好之后再启动解码 |
336 | pDecManager->startDecodeByName(config.name); | 334 | pDecManager->startDecodeByName(config.name); |
337 | cout << "started task: " << config.name << endl; | 335 | cout << "started task: " << config.name << endl; |
336 | + | ||
337 | + return 0; | ||
338 | } | 338 | } |
339 | 339 | ||
340 | // 启动算法处理线程 | 340 | // 启动算法处理线程 |
@@ -356,7 +356,8 @@ void CMultiSourceProcess::post_decode_thread(decode_cbk_userdata* userPtr, AVFra | @@ -356,7 +356,8 @@ void CMultiSourceProcess::post_decode_thread(decode_cbk_userdata* userPtr, AVFra | ||
356 | FFNvDecoder* dec = (FFNvDecoder*)ptr->opaque1; | 356 | FFNvDecoder* dec = (FFNvDecoder*)ptr->opaque1; |
357 | 357 | ||
358 | if (gpuFrame->format == AV_PIX_FMT_CUDA && dec != nullptr){ | 358 | if (gpuFrame->format == AV_PIX_FMT_CUDA && dec != nullptr){ |
359 | - // cout << "decode task: " << dec->getName() << " gpuid: " << gpu_id_ << endl; | 359 | + // std::this_thread::sleep_for(std::chrono::milliseconds(25)); |
360 | + // cout << "decode task: " << dec->getName() << " gpuid: " << gpu_id_ << " " << gpuFrame->width << " " <<gpuFrame->height<< endl; | ||
360 | GpuRgbMemory* gpuMem = new GpuRgbMemory(3, gpuFrame->width, gpuFrame->height, dec->getName(), gpu_id_ , true); | 361 | GpuRgbMemory* gpuMem = new GpuRgbMemory(3, gpuFrame->width, gpuFrame->height, dec->getName(), gpu_id_ , true); |
361 | 362 | ||
362 | if (gpuMem->getMem() == nullptr){ | 363 | if (gpuMem->getMem() == nullptr){ |
@@ -458,7 +459,11 @@ bool CMultiSourceProcess::task_has_vpt_algor(const std::string &task_id){ | @@ -458,7 +459,11 @@ bool CMultiSourceProcess::task_has_vpt_algor(const std::string &task_id){ | ||
458 | 459 | ||
459 | bool CMultiSourceProcess::task_has_face_algor(const std::string &task_id){ | 460 | bool CMultiSourceProcess::task_has_face_algor(const std::string &task_id){ |
460 | auto algor_map = m_task_param_manager->get_task_other_param(task_id); | 461 | auto algor_map = m_task_param_manager->get_task_other_param(task_id); |
461 | - return algor_map->find(algorithm_type_t::FACE_SNAPSHOT) != algor_map->end(); | 462 | + if (nullptr != algor_map){ |
463 | + return algor_map->find(algorithm_type_t::FACE_SNAPSHOT) != algor_map->end(); | ||
464 | + } | ||
465 | + | ||
466 | + return false; | ||
462 | } | 467 | } |
463 | 468 | ||
464 | void CMultiSourceProcess::cuda_free_wrap(sy_img &img) { | 469 | void CMultiSourceProcess::cuda_free_wrap(sy_img &img) { |
@@ -1249,7 +1254,7 @@ bool CMultiSourceProcess::finish_task(const string taskID, const bool delete_sna | @@ -1249,7 +1254,7 @@ bool CMultiSourceProcess::finish_task(const string taskID, const bool delete_sna | ||
1249 | #ifdef WITH_FACE_DET_SS | 1254 | #ifdef WITH_FACE_DET_SS |
1250 | // 人脸任务结束 | 1255 | // 人脸任务结束 |
1251 | auto task_param_ptr = m_task_param_manager->get_task_algor_param(taskID); | 1256 | auto task_param_ptr = m_task_param_manager->get_task_algor_param(taskID); |
1252 | - if (task_param_ptr->human_face_algors.find(algorithm_type_t::FACE_SNAPSHOT) != | 1257 | + if (task_param_ptr != nullptr && task_param_ptr->human_face_algors.find(algorithm_type_t::FACE_SNAPSHOT) != |
1253 | task_param_ptr->human_face_algors.end()) { | 1258 | task_param_ptr->human_face_algors.end()) { |
1254 | m_face_det_ai_engine.finish_task(taskID); | 1259 | m_face_det_ai_engine.finish_task(taskID); |
1255 | } | 1260 | } |
tsl_aiplatform/ai_platform/MultiSourceProcess.h
@@ -133,7 +133,7 @@ public: | @@ -133,7 +133,7 @@ public: | ||
133 | #endif | 133 | #endif |
134 | 134 | ||
135 | /* task api */ | 135 | /* task api */ |
136 | - bool AddTask(task_param _cur_task_param); | 136 | + int AddTask(task_param _cur_task_param); |
137 | bool PauseTask(const string taskID); | 137 | bool PauseTask(const string taskID); |
138 | bool RestartTask(const string taskID); | 138 | bool RestartTask(const string taskID); |
139 | bool FinishTask(const string taskID); | 139 | bool FinishTask(const string taskID); |
tsl_aiplatform/ai_platform/header.h
@@ -13,11 +13,11 @@ | @@ -13,11 +13,11 @@ | ||
13 | 13 | ||
14 | #define DETECTTYPE 9 | 14 | #define DETECTTYPE 9 |
15 | // #define MTASK_DEBUG_ | 15 | // #define MTASK_DEBUG_ |
16 | -#define WITH_FACE_DET_SS | ||
17 | 16 | ||
18 | enum class algorithm_type_t { | 17 | enum class algorithm_type_t { |
19 | PLACEHOLDER = -2, | 18 | PLACEHOLDER = -2, |
20 | UNKNOWN = -1, | 19 | UNKNOWN = -1, |
20 | + VIDEO_SNAPSHOT = 100, // 220802byzsh 视频快照 | ||
21 | FACE_SNAPSHOT = 101, | 21 | FACE_SNAPSHOT = 101, |
22 | HUMAN_SNAPSHOT = 201, | 22 | HUMAN_SNAPSHOT = 201, |
23 | 23 | ||
@@ -30,6 +30,7 @@ enum class algorithm_type_t { | @@ -30,6 +30,7 @@ enum class algorithm_type_t { | ||
30 | NO_SAFETY_HELMET = 209, | 30 | NO_SAFETY_HELMET = 209, |
31 | PEDESTRIAN_RETROGRADE = 210, | 31 | PEDESTRIAN_RETROGRADE = 210, |
32 | PEDESTRIAN_TRESPASS = 211, | 32 | PEDESTRIAN_TRESPASS = 211, |
33 | + ROAD_WORK_DET = 212, // 221026byzsh施工占道 | ||
33 | 34 | ||
34 | VEHICLE_SNAPSHOT = 301, | 35 | VEHICLE_SNAPSHOT = 301, |
35 | VEHICLE_RETROGRADE = 310, | 36 | VEHICLE_RETROGRADE = 310, |
@@ -256,6 +257,19 @@ typedef struct algor_config_param_human_gather { | @@ -256,6 +257,19 @@ typedef struct algor_config_param_human_gather { | ||
256 | 257 | ||
257 | 258 | ||
258 | 259 | ||
260 | +// 施工占道参数结构体 221026byzsh | ||
261 | +#ifndef ___ROAD_WORK_ALGOR_CONFIG_PARAM__ | ||
262 | +#define ___ROAD_WORK_ALGOR_CONFIG_PARAM__ | ||
263 | +typedef struct algor_config_param_road_work { | ||
264 | + int frame_stride; //推送间隔(实际间隔 = frame_stride * 内部跳帧数) | ||
265 | + int rblock_count_threshold; //报警阈值 | ||
266 | + algor_config_param_road_work() | ||
267 | + : frame_stride(1), rblock_count_threshold(3) {} | ||
268 | +} algor_config_param_road_work; | ||
269 | +#endif // #ifndef ___ROAD_WORK_ALGOR_CONFIG_PARAM__ | ||
270 | + | ||
271 | + | ||
272 | + | ||
259 | // 人员跌倒参数结构体 | 273 | // 人员跌倒参数结构体 |
260 | #ifndef ___PEDESTRIAN_FALL_ALGOR_CONFIG_PARAM__ | 274 | #ifndef ___PEDESTRIAN_FALL_ALGOR_CONFIG_PARAM__ |
261 | #define ___PEDESTRIAN_FALL_ALGOR_CONFIG_PARAM__ | 275 | #define ___PEDESTRIAN_FALL_ALGOR_CONFIG_PARAM__ |
@@ -460,7 +474,7 @@ enum class mq_type_t { | @@ -460,7 +474,7 @@ enum class mq_type_t { | ||
460 | GET_TASK_MQ = 1, | 474 | GET_TASK_MQ = 1, |
461 | HEART_BEAT_MQ = 2, | 475 | HEART_BEAT_MQ = 2, |
462 | ALARM_MQ = 3, | 476 | ALARM_MQ = 3, |
463 | - | 477 | + SCREENSHORT_TASK_MQ = 4, // 220809 视频截图队列 |
464 | // DEL_TASK = 0, | 478 | // DEL_TASK = 0, |
465 | // GET_TASK = 1, | 479 | // GET_TASK = 1, |
466 | // HEART_BEAT = 2, | 480 | // HEART_BEAT = 2, |