Blame view

src/util/vpc_util.h 1.39 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
  #ifndef ___VPC_UTIL_H__
  #define ___VPC_UTIL_H__
  
  #include "acl/acl.h"
  #include "acl/ops/acl_dvpp.h"
  #include "acl/dvpp/hi_dvpp.h"
  #include "../ai_platform/header.h"
  
  #include <string>
  #include <vector>
  
  using namespace std;
  
  struct vpc_img_info{
      acldvppPicDesc* pic_desc{nullptr};
      string task_id;              //该物体属于的任务ID
      int task_frame_count;     //该物体当前出现的帧号
      int object_id;            //该物体的ID
      int index;                //该物体所属类别的编号
      double confidence;        //该物体的置信度
  };
  
  class DeviceMemory;
  
  class VPCUtil {
  
  public:
      static VPCUtil* getInstance(){
  		static VPCUtil* singleton = nullptr;
  		if (singleton == nullptr){
  			singleton = new VPCUtil();
  		}
  		return singleton;
  	}
  
      ~VPCUtil()
      {
          release();
      }
  
      static void vpc_pic_desc_release(acldvppPicDesc* );
  
      static void vpc_img_release(vpc_img_info );
  
      static void vpc_imgList_release(vector<vpc_img_info>& );
  
      static vpc_img_info vpc_devMem2vpcImg(DeviceMemory *devMem);
  
  public:
      vpc_img_info crop(DeviceMemory *devMem, video_object_info obj);
  
      int init(int32_t devId);
  
      vector<vpc_img_info> crop_batch(DeviceMemory *devMem, vector<video_object_info> objs);
  
      void release();
  
  private:
      int32_t deviceId_;
      aclrtContext context_;
  
      acldvppChannelDesc *dvppChannelDesc_;
  };
  
  
  
  #endif  //___VPC_UTIL_H__