Blame view

src/ai_engine_module/VidClothes.cpp 1.55 KB
15756629   Hu Chunming   添加clothes算法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  #include "VidClothes.h"
  
  VidClothes::VidClothes(/* args */)
  {
  }
  
  VidClothes::~VidClothes()
  {
      release();
  }
  
  int VidClothes::init(int devId){
      ACL_CALL(aclrtCreateContext(&ctx, devId), SY_SUCCESS, SY_FAILED);
  
      vidclothes_param param;
      param.modelNames = "./models/vid_clothes/vidClothes0325_310P.om";
      param.thresld = 0.0;
4a273a4a   Hu Chunming   添加hcp和hp
18
      param.devId = devId;
15756629   Hu Chunming   添加clothes算法
19
  
4a273a4a   Hu Chunming   添加hcp和hp
20
      cout << "vidclothes_init start " << endl;
15756629   Hu Chunming   添加clothes算法
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
      int ret = vidclothes_init(&m_handle, param);
      if (ret != 0) {
          return -1;
  	}
  
      cout << "vidclothes_init success " << endl;
  
      return SY_SUCCESS;
  }
  
  int VidClothes::detect(vector<sy_img> vec_img){
  
      ACL_CALL(aclrtSetCurrentContext(ctx), SY_SUCCESS, SY_FAILED);	
  
      const int batchsize = vec_img.size();
      vidclothes_result * results = new vidclothes_result[batchsize];
  
      int ret = SY_FAILED;
  
      do
      {
          ret = vidclothes_batch(m_handle, vec_img.data(), batchsize, results);
          if (SY_SUCCESS != ret) {
              printf("vidclothesClassification process failed!");
              break;
          }
          
          for(int batchIdx = 0;batchIdx<batchsize;batchIdx++) {    
              printf("index:%d,confidence:%f\n",results[batchIdx].index,results[batchIdx].score);
          }
      } while (0);
  
      if (results) {
          delete [] results;
      }
  
      return ret;
  }
  
4a273a4a   Hu Chunming   添加hcp和hp
60
61
62
  int VidClothes::release() {
  
      ACL_CALL(aclrtSetCurrentContext(ctx), SY_SUCCESS, SY_FAILED);	
15756629   Hu Chunming   添加clothes算法
63
64
65
66
  
      if (m_handle) {
          vidclothes_release(&m_handle);
      }
4a273a4a   Hu Chunming   添加hcp和hp
67
68
69
70
71
72
73
  
      if(ctx){
          aclrtDestroyContext(ctx);
          ctx = nullptr;
      }
  
      return SY_SUCCESS;
15756629   Hu Chunming   添加clothes算法
74
  }