Commit 6e2b079ea9bb0b02a61c1d329235943fafbc1ba0

Authored by Hu Chunming
1 parent fccbe006

编译通过

FFNvDecoder/NV12ToRGB.cu
... ... @@ -257,14 +257,14 @@ namespace cuda_common
257 257 dstImage[width * y * 3 + x * 3 + 5] = clip_v(red[1] * 0.25,0 ,255);
258 258 }
259 259  
260   - cudaError_t setColorSpace2(e_ColorSpace CSC, float hue)
  260 + cudaError_t setColorSpace(FF_ColorSpace CSC, float hue)
261 261 {
262 262  
263 263 float hueSin = sin(hue);
264 264 float hueCos = cos(hue);
265 265  
266 266 float hueCSC[9];
267   - if (CSC == ITU601)
  267 + if (CSC == ITU_601)
268 268 {
269 269 //CCIR 601
270 270 hueCSC[0] = 1.1644f;
... ... @@ -277,7 +277,7 @@ namespace cuda_common
277 277 hueCSC[7] = hueCos * 2.0172f;
278 278 hueCSC[8] = hueSin * -2.0172f;
279 279 }
280   - else if (CSC == ITU709)
  280 + else if (CSC == ITU_709)
281 281 {
282 282 //CCIR 709
283 283 hueCSC[0] = 1.0f;
... ...
FFNvDecoder/cuda_kernels.h
... ... @@ -12,13 +12,13 @@
12 12  
13 13 typedef enum
14 14 {
15   - ITU601 = 1,
16   - ITU709 = 2
17   -} e_ColorSpace;
  15 + ITU_601 = 1,
  16 + ITU_709 = 2
  17 +} FF_ColorSpace;
18 18  
19 19 namespace cuda_common
20 20 {
21   - cudaError_t setColorSpace2(e_ColorSpace CSC, float hue);
  21 + cudaError_t setColorSpace(FF_ColorSpace CSC, float hue);
22 22  
23 23 cudaError_t NV12ToRGBnot(CUdeviceptr d_srcNV12, size_t nSourcePitch, unsigned char* d_dstRGB, int width, int height);
24 24 cudaError_t CUDAToBGR(CUdeviceptr dataY, CUdeviceptr dataUV, size_t pitchY, size_t pitchUV, unsigned char* d_dstRGB, int width, int height);
... ...
tsl_aiplatform/ai_engine_module/VPTProcess.h
... ... @@ -65,6 +65,10 @@ int VPT_Process_GPU(void * handle, sy_img * batch_img, int batchsize, vector<on
65 65 vector<vector<onelevel_det_result>>& unUsedResult);
66 66  
67 67  
  68 +int VPT_Process_GPU2(void * handle, sy_img * batch_img, vector<string>& tasklist,
  69 + vector<onelevel_det_result>& result, vector<vector<int>>& deleteObjectID, vector<vector<onelevel_det_result>>& unUsedResult);
  70 +
  71 +
68 72 /*************************************************************************
69 73 * FUNCTION: VPT_Release
70 74 * PURPOSE: 资源释放
... ...
tsl_aiplatform/ai_engine_module/face_det_ai_engine.cpp
1 1 #include "face_det_ai_engine.h"
2 2 #include <cuda.h>
3 3 #include <cuda_runtime.h>
4   -#include "cuda_kernels.h"
5 4 #include "mvpt_process_assist.h"
6 5  
7 6 #include "../helpers/logger.hpp"
... ... @@ -402,7 +401,7 @@ int face_det_ai_engine::ai_engine_process_batch2(std::vector&lt;std::string&gt; &amp;task_
402 401  
403 402 //跟踪
404 403 int real_index = 0;
405   - std::set<std::string>::iterator iter = task_ids.cbegin();
  404 + auto iter = task_ids.cbegin();
406 405 while (iter != task_ids.cend())
407 406 {
408 407 if (!task_trackers[*iter].tracker.GetState())
... ...
tsl_aiplatform/ai_engine_module/human_gather_statistics.cpp
... ... @@ -83,7 +83,7 @@ namespace ai_engine_module
83 83 return results;
84 84 }
85 85  
86   - std::vector<result_data_t> human_gather_statistics_process2(vector<string>& taskin_play_id, sy_img* images, vector<onelevel_det_result> &ol_det_result)
  86 + std::vector<result_data_t> human_gather_statistics::human_gather_statistics_process2(vector<string>& taskin_play_id, sy_img* images, vector<onelevel_det_result> &ol_det_result)
87 87 {
88 88 std::vector<result_data_t> results;
89 89  
... ...
tsl_aiplatform/ai_engine_module/human_gather_statistics.h
... ... @@ -38,6 +38,7 @@ namespace ai_engine_module
38 38 public:
39 39 int human_gather_statistics_init();
40 40 std::vector<result_data_t> human_gather_statistics_process(set<string>& taskin_play_id, sy_img* images, vector<onelevel_det_result> &ol_det_result);
  41 + std::vector<result_data_t> human_gather_statistics_process2(vector<string>& taskin_play_id, sy_img* images, vector<onelevel_det_result> &ol_det_result);
41 42 };
42 43 }
43 44 }
44 45 \ No newline at end of file
... ...
tsl_aiplatform/ai_platform/GpuRgbMemory.hpp
1 1 #include<string>
2 2  
3 3 #include "../helpers/cuda_helper.h"
4   -#include "../helpers/timer.h"
  4 +#include "../helpers/timer.hpp"
5 5  
6 6 using namespace std;
7 7  
8 8 class GpuRgbMemory{
9 9  
10 10 public:
11   - GpuRgbMemory(, int _channel, int _width, int _height, string _id, string _gpuid, bool _isused){
  11 + GpuRgbMemory(int _channel, int _width, int _height, string _id, string _gpuid, bool _isused){
12 12 channel = _channel;
13 13 width = _width;
14 14 height = _height;
... ... @@ -41,7 +41,7 @@ public:
41 41 void setIsused(bool _isused) {
42 42 isused = _isused;
43 43 // 更新时间戳
44   - timestamp = helpers::timer::get_timestamp<std::chrono::milliseconds>()
  44 + timestamp = helpers::timer::get_timestamp<std::chrono::milliseconds>();
45 45 }
46 46  
47 47 string getId() {
... ...
tsl_aiplatform/ai_platform/GpuRgbMemoryFactory.cpp
... ... @@ -31,7 +31,7 @@ GpuRgbMemory* GpuRgbMemoryFactory::getMemory(int size, string id, string gpuid){
31 31 }
32 32  
33 33 // 没有找到,或者找到了但是不符合需求重新分配
34   - GpuRgbMemory* mem = new GpuRgbMemory(size, true, id, gpuid);
  34 + GpuRgbMemory* mem = nullptr; //new GpuRgbMemory(size, true, id, gpuid);
35 35 memoryMap[id] = mem;
36 36 return mem;
37 37 }
... ...
tsl_aiplatform/ai_platform/MultiSourceProcess.cpp
1 1 #include "MultiSourceProcess.h"
2 2  
  3 +#ifdef POST_USE_RABBITMQ
  4 + #include "../helpers/gen_json.hpp"
  5 +#endif
  6 +
  7 +#include "../helpers/logger.hpp"
  8 +#include "../helpers/os_helper.hpp"
3 9  
4 10 #include "authority.h"
5 11  
... ... @@ -296,8 +302,8 @@ void CMultiSourceProcess::post_decode_thread(task_param _cur_task_param, AVFrame
296 302 GpuRgbMemory* gpuMem = new GpuRgbMemory(3, gpuFrame->width, gpuFrame->height, _cur_task_param.task_id, _cur_task_param.gpu_id_ , true);
297 303  
298 304 cudaSetDevice(atoi(_cur_task_param.gpu_id_));
299   - cuda_common::setColorSpace2( ITU709, 0 );
300   - cudaError_t cudaStatus = cuda_common::CUDAToBGR((CUdeviceptr)gpuFrame->data[0],(CUdeviceptr)gpuFrame->data[1], gpuFrame->linesize[0], gpuFrame->linesize[1], gpuMem->pHwRgb, gpuFrame->width, gpuFrame->height);
  305 + cuda_common::setColorSpace( ITU_709, 0 );
  306 + cudaError_t cudaStatus = cuda_common::CUDAToBGR((CUdeviceptr)gpuFrame->data[0],(CUdeviceptr)gpuFrame->data[1], gpuFrame->linesize[0], gpuFrame->linesize[1], gpuMem->getMem(), gpuFrame->width, gpuFrame->height);
301 307 cudaDeviceSynchronize();
302 308 if (cudaStatus != cudaSuccess) {
303 309 cout << "CUDAToBGR failed !!!" << endl;
... ... @@ -446,7 +452,7 @@ void CMultiSourceProcess::algorthim_vpt(vector&lt;string&gt;&amp; task_list, sy_img *batch
446 452 continue;
447 453  
448 454 vpt_interest_task_id.push_back(task_id);
449   - vpt_interest_imgs.emplace_back(batch_img[_idx]);
  455 + vpt_interest_imgs.emplace_back(batch_img[i]);
450 456 }
451 457  
452 458 /* 待检测的图片不为空 开始检测 */
... ... @@ -493,8 +499,11 @@ void CMultiSourceProcess::algorthim_vpt(vector&lt;string&gt;&amp; task_list, sy_img *batch
493 499  
494 500 // 行人安全分析算法模块
495 501 void CMultiSourceProcess::algorthim_pedestrian_safety(vector<string>& vpt_interest_task_id, vector<sy_img>& vpt_interest_imgs, vector<onelevel_det_result>& vptResult){
  502 +
  503 +#ifdef WITH_SECOND_PROCESS
  504 +
496 505 vector<string> interest_task_id;
497   - decltype(vptResult) interest_vpt_result;
  506 + vector<onelevel_det_result> interest_vpt_result;
498 507 vector<sy_img> interest_imgs(0);
499 508  
500 509 int _idx = 0;
... ... @@ -516,11 +525,14 @@ void CMultiSourceProcess::algorthim_pedestrian_safety(vector&lt;string&gt;&amp; vpt_intere
516 525  
517 526 if (!interest_imgs.empty())
518 527 pedestrian_safety_detector_.update_mstreams2(interest_task_id, interest_imgs.data(), interest_vpt_result);
  528 +
  529 +#endif
519 530 }
520 531  
521 532 // 逆行&非法闯入算法模块
522 533 void CMultiSourceProcess::algorthim_retrograde_trespass(vector<string>& vpt_interest_task_id, vector<sy_img>& vpt_interest_imgs, vector<onelevel_det_result>& vptResult
523 534 ,vector<vector<int>>& deleteObjectID){
  535 +#ifdef WITH_SECOND_PROCESS
524 536 vector<string> interest_task_id;
525 537 decltype(vptResult) interest_vpt_result;
526 538 vector<sy_img> interest_imgs(0);
... ... @@ -562,6 +574,7 @@ void CMultiSourceProcess::algorthim_retrograde_trespass(vector&lt;string&gt;&amp; vpt_inte
562 574 trespass_interest_task_id, trespass_interest_imgs.data(), trespass_interest_vpt_result,
563 575 trespass_interest_deleteobjs);
564 576 }
  577 +#endif
565 578 }
566 579  
567 580 // for snapshot algorithm. 轨迹结束目标 做最后的结果返回(当前返回算法结果+快照保存路径)
... ... @@ -810,9 +823,11 @@ int CMultiSourceProcess::endframe_obj_process(const OBJ_KEY &amp;obj_key, algorithm_
810 823  
811 824 // 打架跌倒算法模块
812 825 void CMultiSourceProcess::algorithm_fight_fall(vector<string>& vpt_interest_task_id, vector<sy_img>& vpt_interest_imgs, vector<onelevel_det_result>& vptResult){
  826 +
  827 +#ifdef WITH_SECOND_PROCESS
813 828 /* a. find fight or fall classification taskId. */
814 829 vector<string> interest_task_id;
815   - decltype(vptResult) interest_vpt_result;
  830 + vector<onelevel_det_result> interest_vpt_result;
816 831 vector<sy_img> interest_imgs(0);
817 832  
818 833 int _idx = 0;
... ... @@ -820,7 +835,7 @@ void CMultiSourceProcess::algorithm_fight_fall(vector&lt;string&gt;&amp; vpt_interest_task
820 835 ++_task_id_iter, ++_idx) // loop task_id;
821 836 {
822 837 const auto &task_id = *_task_id_iter;
823   - auto algor_map = pThreadParam->m_task_param_manager->get_task_other_param(task_id);
  838 + auto algor_map = m_task_param_manager->get_task_other_param(task_id);
824 839 if (algor_map->find(algorithm_type_t::PEDESTRIAN_FIGHT) != algor_map->end() ||
825 840 algor_map->find(algorithm_type_t::PEDESTRIAN_FALL) != algor_map->end()) {
826 841 interest_task_id.emplace_back(task_id);
... ... @@ -853,32 +868,39 @@ void CMultiSourceProcess::algorithm_fight_fall(vector&lt;string&gt;&amp; vpt_interest_task
853 868 }
854 869 }
855 870 }
  871 +
  872 +#endif
856 873 }
857 874  
858   -void CMultiSourceProcess::algorithm_takeaway_member_cls(vector<string>& vpt_interest_task_id, vector<sy_img>& vpt_interest_imgs, vector<onelevel_det_result>& vptResult){
859   - /* find takeaway member classification taskId. */
860   - vector<string> interest_task_id;
861   - decltype(vptResult) interest_vpt_result;
862   - vector<sy_img> interest_imgs(0);
  875 +void CMultiSourceProcess::algorithm_takeaway_member_cls(vector<string>& vpt_interest_task_id, vector<sy_img>& vpt_interest_imgs
  876 + , vector<onelevel_det_result>& vptResult){
863 877  
864   - int _idx = 0;
865   - for (auto _task_id_iter = vpt_interest_task_id.begin(); _task_id_iter != vpt_interest_task_id.end();
866   - ++_task_id_iter, ++_idx) // loop task_id;
867   - {
868   - const auto &task_id = *_task_id_iter;
  878 +#ifdef WITH_SECOND_PROCESS
  879 + /* find takeaway member classification taskId. */
  880 + vector<string> interest_task_id;
  881 + decltype(vptResult) interest_vpt_result;
  882 + vector<sy_img> interest_imgs(0);
869 883  
870   - auto algor_map = pThreadParam->m_task_param_manager->get_task_other_param(task_id);
871   - if (algor_map->find(algorithm_type_t::TAKEAWAY_MEMBER_CLASSIFICATION) == algor_map->end())
872   - continue;
  884 + int _idx = 0;
  885 + for (auto _task_id_iter = vpt_interest_task_id.begin(); _task_id_iter != vpt_interest_task_id.end();
  886 + ++_task_id_iter, ++_idx) // loop task_id;
  887 + {
  888 + const auto &task_id = *_task_id_iter;
873 889  
874   - interest_task_id.emplace_back(task_id);
875   - interest_imgs.emplace_back(vpt_interest_imgs[_idx]);
876   - interest_vpt_result.emplace_back(vptResult[_idx]);
877   - }
  890 + auto algor_map = pThreadParam->m_task_param_manager->get_task_other_param(task_id);
  891 + if (algor_map->find(algorithm_type_t::TAKEAWAY_MEMBER_CLASSIFICATION) == algor_map->end())
  892 + continue;
878 893  
879   - if (!interest_imgs.empty())
880   - takeaway_member_.update_mstreams2(interest_task_id, interest_imgs.data(), interest_vpt_result);
881   - }
  894 + interest_task_id.emplace_back(task_id);
  895 + interest_imgs.emplace_back(vpt_interest_imgs[_idx]);
  896 + interest_vpt_result.emplace_back(vptResult[_idx]);
  897 + }
  898 +
  899 + if (!interest_imgs.empty())
  900 + takeaway_member_.update_mstreams2(interest_task_id, interest_imgs.data(), interest_vpt_result);
  901 +
  902 +#endif
  903 +}
882 904  
883 905 /* 每帧都需要做的算法模块 */
884 906 int CMultiSourceProcess::everyframe_process(vector<string> &task_in_play_id, sy_img *images,
... ... @@ -988,7 +1010,7 @@ void CMultiSourceProcess::algorthim_face_detect(vector&lt;string&gt;&amp; task_list, sy_im
988 1010 if (!task_has_face_algor(task_id))
989 1011 continue;
990 1012  
991   - face_det_interest_task_id.insert(task_id);
  1013 + face_det_interest_task_id.emplace_back(task_id);
992 1014 face_det_interest_imgs.emplace_back(batch_img[_idx]);
993 1015 }
994 1016  
... ...
tsl_aiplatform/ai_platform/MultiSourceProcess.h
... ... @@ -173,12 +173,8 @@ public:
173 173  
174 174 /* frame process api */
175 175 int FinishProcessThread();
176   - int endframe_obj_process(const OBJ_KEY &obj_key, algorithm_type_t algor_type);
  176 +
177 177 int everyframe_process(vector<string> &task_in_play_id, sy_img *images, vector<onelevel_det_result> &ol_det_result);
178   - bool save_snapshot_process(const OBJ_KEY &obj_key, const algorithm_type_t &algorithm_type, const sy_img &ori_img,
179   - const sy_img &roi_img, const long long id, const std::string &json_str,
180   - bool enable_async = true, const bool ori_img_is_in_gpu = true,
181   - const bool roi_img_is_in_gpu = true);
182 178  
183 179 public:
184 180 void algorthim_process_thread(const string gpuid);
... ... @@ -214,10 +210,10 @@ private:
214 210 int endframe_obj_process(const OBJ_KEY &obj_key, algorithm_type_t algor_type);
215 211 /* 实现快照保存功能(还未真正保存 将显存图片cp到内存
216 212 * 直接保存本地或者存入缓存队列异步保存,保存方式看需求,报警类需要同步保存报警,分析类可异步保存后返回)*/
217   -bool save_snapshot_process(const OBJ_KEY &obj_key, const algorithm_type_t &algorithm_type,
  213 + bool save_snapshot_process(const OBJ_KEY &obj_key, const algorithm_type_t &algorithm_type,
218 214 const sy_img &ori_img, const sy_img &roi_img, const long long id,
219 215 const std::string &json_str, bool enable_async,
220   - const bool ori_img_is_in_gpu, const bool roi_img_is_in_gpu)
  216 + const bool ori_img_is_in_gpu, const bool roi_img_is_in_gpu);
221 217  
222 218 private:
223 219 map<string, pthread_t*> gpuProcessthreadMap;
... ...