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 | 9 | |
10 | 10 | #include "authority.h" |
11 | 11 | |
12 | -#include "NvJpegEncoder.hpp" | |
13 | - | |
14 | 12 | #ifdef AUTHORIZATION |
15 | 13 | #include <boost/thread.hpp> |
16 | 14 | #ifdef _MSC_VER |
... | ... | @@ -270,7 +268,7 @@ int CMultiSourceProcess::InitAlgorthim(tsl_aiplatform_param vptParam) { |
270 | 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 | 273 | FFNvDecoderManager* pDecManager = FFNvDecoderManager::getInstance(); |
276 | 274 | |
... | ... | @@ -286,7 +284,7 @@ bool CMultiSourceProcess::AddTask(task_param _cur_task_param){ |
286 | 284 | FFNvDecoder* dec = pDecManager->createDecoder(config); |
287 | 285 | if (!dec) |
288 | 286 | { |
289 | - return false; | |
287 | + return -1; | |
290 | 288 | } |
291 | 289 | |
292 | 290 | decode_cbk_userdata* userPtr = new decode_cbk_userdata; |
... | ... | @@ -335,6 +333,8 @@ bool CMultiSourceProcess::AddTask(task_param _cur_task_param){ |
335 | 333 | // 所有参数都准备好之后再启动解码 |
336 | 334 | pDecManager->startDecodeByName(config.name); |
337 | 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 | 356 | FFNvDecoder* dec = (FFNvDecoder*)ptr->opaque1; |
357 | 357 | |
358 | 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 | 361 | GpuRgbMemory* gpuMem = new GpuRgbMemory(3, gpuFrame->width, gpuFrame->height, dec->getName(), gpu_id_ , true); |
361 | 362 | |
362 | 363 | if (gpuMem->getMem() == nullptr){ |
... | ... | @@ -458,7 +459,11 @@ bool CMultiSourceProcess::task_has_vpt_algor(const std::string &task_id){ |
458 | 459 | |
459 | 460 | bool CMultiSourceProcess::task_has_face_algor(const std::string &task_id){ |
460 | 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 | 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 | 1254 | #ifdef WITH_FACE_DET_SS |
1250 | 1255 | // 人脸任务结束 |
1251 | 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 | 1258 | task_param_ptr->human_face_algors.end()) { |
1254 | 1259 | m_face_det_ai_engine.finish_task(taskID); |
1255 | 1260 | } | ... | ... |
tsl_aiplatform/ai_platform/MultiSourceProcess.h
... | ... | @@ -133,7 +133,7 @@ public: |
133 | 133 | #endif |
134 | 134 | |
135 | 135 | /* task api */ |
136 | - bool AddTask(task_param _cur_task_param); | |
136 | + int AddTask(task_param _cur_task_param); | |
137 | 137 | bool PauseTask(const string taskID); |
138 | 138 | bool RestartTask(const string taskID); |
139 | 139 | bool FinishTask(const string taskID); | ... | ... |
tsl_aiplatform/ai_platform/header.h
... | ... | @@ -13,11 +13,11 @@ |
13 | 13 | |
14 | 14 | #define DETECTTYPE 9 |
15 | 15 | // #define MTASK_DEBUG_ |
16 | -#define WITH_FACE_DET_SS | |
17 | 16 | |
18 | 17 | enum class algorithm_type_t { |
19 | 18 | PLACEHOLDER = -2, |
20 | 19 | UNKNOWN = -1, |
20 | + VIDEO_SNAPSHOT = 100, // 220802byzsh 视频快照 | |
21 | 21 | FACE_SNAPSHOT = 101, |
22 | 22 | HUMAN_SNAPSHOT = 201, |
23 | 23 | |
... | ... | @@ -30,6 +30,7 @@ enum class algorithm_type_t { |
30 | 30 | NO_SAFETY_HELMET = 209, |
31 | 31 | PEDESTRIAN_RETROGRADE = 210, |
32 | 32 | PEDESTRIAN_TRESPASS = 211, |
33 | + ROAD_WORK_DET = 212, // 221026byzsh施工占道 | |
33 | 34 | |
34 | 35 | VEHICLE_SNAPSHOT = 301, |
35 | 36 | VEHICLE_RETROGRADE = 310, |
... | ... | @@ -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 | 274 | #ifndef ___PEDESTRIAN_FALL_ALGOR_CONFIG_PARAM__ |
261 | 275 | #define ___PEDESTRIAN_FALL_ALGOR_CONFIG_PARAM__ |
... | ... | @@ -460,7 +474,7 @@ enum class mq_type_t { |
460 | 474 | GET_TASK_MQ = 1, |
461 | 475 | HEART_BEAT_MQ = 2, |
462 | 476 | ALARM_MQ = 3, |
463 | - | |
477 | + SCREENSHORT_TASK_MQ = 4, // 220809 视频截图队列 | |
464 | 478 | // DEL_TASK = 0, |
465 | 479 | // GET_TASK = 1, |
466 | 480 | // HEART_BEAT = 2, | ... | ... |