Blame view

src/ai_engine_module/VPTProcess.h 2.48 KB
09c2d08c   Hu Chunming   arm交付版
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
  /*******************************************************************************************
  * Version: VPT_x64_V2.0.0_20170705
  * CopyRight: 中科院自动化研究所模式识别实验室图像视频组
  * UpdateDate: 20170705
  * Content: 人车物监测跟踪
  ********************************************************************************************/
  #pragma once
  #include <iostream>
  #include <vector>
  #include <string>
  #include "sort/Sort.h"
  #include "acl/acl.h"
  #include "acl/ops/acl_dvpp.h"
  
  using namespace std;
  
  // #define THRESHOLD 0.45
  #define THRESHOLD 0.3
  
  struct TaskTracker
  {
  	string TaskID;
  	double ratioWidth;
  	double ratioHeight;
  	Sort tracker;
  };
  
  
  typedef struct VPTProcess_PARAM
  {
  	int gpuid;              //指定显卡id
  	float threshold;
  	int max_batch;
  
  	char* serialize_file;
  	char* auth_license;
      string model_dir;
  	VPTProcess_PARAM() : gpuid(0), threshold(0.6), max_batch(20) {};
  }VPTProcess_PARAM;
  
  class VPTProcess {
  
  public:
      VPTProcess();
      ~VPTProcess();
      /*************************************************************************
      * FUNCTION: VPT_Init
      * PURPOSE: 初始化
      * PARAM:
      [in] vparam		参数
      * RETURN:	handle
      * NOTES:
      *************************************************************************/
      int init(VPTProcess_PARAM vparam);
  
  
      /**
       * @brief 人车物检测跟踪
       *
       * @param handle [in]
       * @param batch_img [in]
       * @param batchsize [in]
       * @param result [in]
       * @param deleteObjectID [in]
       * @param unUsedResult [in]
       * @param class_label_count [in/out]
       * @return int -1:图像错误; 其他:检测到的个数
       */
      int process_gpu(sy_img * batch_img, vector<string>& tasklist, 
                          vector<onelevel_det_result>& result, vector<vector<int>>& deleteObjectID, vector<vector<onelevel_det_result>>& unUsedResult);
  
  
      /*************************************************************************
      * FUNCTION: VPT_Release
      * PURPOSE: 资源释放
      * PARAM:
      [in] handle		- 处理句柄
      * RETURN:	NULL
      * NOTES:
      *************************************************************************/
      void release();
  
  
      void addTaskTracker(const string taskID, double rWidth =1, double rHeight=1, int skip_frame=5); //221117byzsh
      bool finishTaskTracker(const string taskID);
  
  private:
      int m_devId; 
      aclrtContext m_algorthim_ctx;
  
      void* m_det_handle{nullptr};
  	float threshold{0.6};
  	int m_max_batchsize;
  	map<string, TaskTracker> taskTrackers;
  };