Commit 667e7a901ce4e1aa715a09d37ef9b6fba1093870

Authored by Hu Chunming
1 parent b3012672

雨棚和打电话初步代码

src/PicAnalysis.cpp
... ... @@ -22,13 +22,13 @@ int PicAnalysis::init(int dev_id) {
22 22 return -1;
23 23 }
24 24  
25   - head_tail_param ht_param;
26   - ht_param.devId = dev_id;
27   - ht_param.max_batch = 16;
28   - ret = m_head_tail_algorithm.init(ht_param);
29   - if(0 != ret){
30   - return -1;
31   - }
  25 + // head_tail_param ht_param;
  26 + // ht_param.devId = dev_id;
  27 + // ht_param.max_batch = 16;
  28 + // ret = m_head_tail_algorithm.init(ht_param);
  29 + // if(0 != ret){
  30 + // return -1;
  31 + // }
32 32  
33 33 ret = m_clothes_algorithm.init(dev_id);
34 34 if(0 != ret){
... ... @@ -119,7 +119,7 @@ int PicAnalysis::analysis_sync(vector<string> vec_file_path){
119 119 ImageData src = dvpp_data[b];
120 120 for(int c=0;c<result[b].count;c++)
121 121 {
122   - vehicle_info result_info = result[b].info[c];
  122 + vehicle_info& result_info = result[b].info[c];
123 123 int shot_type=result[b].info[c].type;
124 124  
125 125 // 行人
... ... @@ -140,6 +140,19 @@ int PicAnalysis::analysis_sync(vector&lt;string&gt; vec_file_path){
140 140  
141 141 delete human_data;
142 142 human_data = nullptr;
  143 + } else if(1 == shot_type) {
  144 + // 车尾,判断是否 货车尾部货厢载人
  145 + if(result_info.vpt_type == 6 || result_info.vpt_type == 7){
  146 + if(result_info.manned_res.hs_count > 0){
  147 + // 货车载人
  148 + }
  149 + }
  150 + } else {
  151 + if(result_info.vpt_type == 1 || result_info.vpt_type == 2 || result_info.vpt_type == 3){
  152 + if(result_info.manned_res.hs_count >= 3){
  153 + // 摩托车、三轮车载人
  154 + }
  155 + }
143 156 }
144 157  
145 158 // 司乘
... ... @@ -189,13 +202,19 @@ int PicAnalysis::analysis_sync(vector&lt;string&gt; vec_file_path){
189 202 vector<sy_img> vec_motor_img;
190 203 vec_motor_img.push_back(img);
191 204  
192   - m_motor_rainshed_algorithm.detect(vec_motor_img);
193   -
194   - m_motor_phone_algorithm.detect(vec_motor_img);
195   -
196   - //
  205 + vector<int> vec_rainshed_result = m_motor_rainshed_algorithm.detect(vec_motor_img);
  206 + if (vec_rainshed_result.size() > 0)
  207 + {
  208 + result_info.rainshed = vec_rainshed_result[0];
  209 + }
197 210  
198 211  
  212 + vector<int> vec_phone_result = m_motor_phone_algorithm.detect(vec_motor_img);
  213 + if (vec_phone_result.size() > 0)
  214 + {
  215 + int phoning = vec_phone_result[0];
  216 + }
  217 +
199 218 delete motor_data;
200 219 motor_data = nullptr;
201 220 }
... ... @@ -203,14 +222,12 @@ int PicAnalysis::analysis_sync(vector&lt;string&gt; vec_file_path){
203 222 }
204 223 }
205 224  
206   - vector<HeadTailResult> head_tail_result;
207   - ret = m_head_tail_algorithm.detect(vec_img, head_tail_result);
208   - if (0 != ret) {
209   - LOG_ERROR("m_head_tail_algorithm failed!");
210   - head_tail_result.clear();
211   - }
212   -
213   -
  225 + // vector<HeadTailResult> head_tail_result;
  226 + // ret = m_head_tail_algorithm.detect(vec_img, head_tail_result);
  227 + // if (0 != ret) {
  228 + // LOG_ERROR("m_head_tail_algorithm failed!");
  229 + // head_tail_result.clear();
  230 + // }
214 231  
215 232 LOG_INFO("analysis_sync finished!");
216 233  
... ...
src/ai_engine_module/MotorPhoneAnalysis.cpp
... ... @@ -29,18 +29,26 @@ int MotorPhoneAnalysis::init(int devId){
29 29 return SY_SUCCESS;
30 30 }
31 31  
32   -int MotorPhoneAnalysis::detect(vector<sy_img> vec_img){
  32 +vector<int> MotorPhoneAnalysis::detect(vector<sy_img> vec_img){
33 33  
34   - ACL_CALL(aclrtSetCurrentContext(ctx), SY_SUCCESS, SY_FAILED);
  34 + vector<int> vec_result;
35 35  
36 36 const int batchsize = vec_img.size();
37   - motor_phone_result * results = new motor_phone_result[batchsize];
  37 +
  38 + vector<motor_phone_result> results;
  39 + results.resize(batchsize);
38 40  
39 41 int ret = SY_FAILED;
40 42  
41 43 do
42 44 {
43   - ret = motor_phone_process_batch(m_handle, vec_img.data(), batchsize, results);
  45 + ret = aclrtSetCurrentContext(ctx);
  46 + if (SY_SUCCESS != ret) {
  47 + printf("aclrtSetCurrentContext failed!");
  48 + break;
  49 + }
  50 +
  51 + ret = motor_phone_process_batch(m_handle, vec_img.data(), batchsize, results.data());
44 52 if (SY_SUCCESS != ret) {
45 53 printf("motor_phone_process_batch failed!");
46 54 break;
... ... @@ -54,11 +62,7 @@ int MotorPhoneAnalysis::detect(vector&lt;sy_img&gt; vec_img){
54 62 }
55 63 } while (0);
56 64  
57   - if (results) {
58   - delete [] results;
59   - }
60   -
61   - return ret;
  65 + return vec_result;
62 66 }
63 67  
64 68 int MotorPhoneAnalysis::release() {
... ...
src/ai_engine_module/MotorPhoneAnalysis.h
... ... @@ -8,7 +8,7 @@ public:
8 8  
9 9 int init(int devId);
10 10  
11   - int detect(vector<sy_img> vec_img);
  11 + vector<int> detect(vector<sy_img> vec_img);
12 12  
13 13 private:
14 14 int release();
... ...
src/ai_engine_module/MotorRainshedAnalysis.cpp
... ... @@ -29,33 +29,38 @@ int MotorRainshedAnalysis::init(int devId){
29 29 return SY_SUCCESS;
30 30 }
31 31  
32   -int MotorRainshedAnalysis::detect(vector<sy_img> vec_img){
  32 +vector<int> MotorRainshedAnalysis::detect(vector<sy_img> vec_img){
33 33  
34   - ACL_CALL(aclrtSetCurrentContext(ctx), SY_SUCCESS, SY_FAILED);
  34 + vector<int> vec_result;
35 35  
36 36 const int batchsize = vec_img.size();
37   - mrc_result * results = new mrc_result[batchsize];
  37 +
  38 + vector<mrc_result> results;
  39 + results.resize(batchsize);
38 40  
39 41 int ret = SY_FAILED;
40 42  
41 43 do
42 44 {
43   - ret = mrc_batch(m_handle, vec_img.data(), batchsize, results);
  45 + ret = aclrtSetCurrentContext(ctx);
  46 + if (SY_SUCCESS != ret) {
  47 + printf("aclrtSetCurrentContext failed!");
  48 + break;
  49 + }
  50 +
  51 + ret = mrc_batch(m_handle, vec_img.data(), batchsize, results.data());
44 52 if (SY_SUCCESS != ret) {
45 53 printf("mrc_batch failed!");
46 54 break;
47 55 }
48 56  
49   - for(int batchIdx = 0;batchIdx<batchsize;batchIdx++){
  57 + for(int batchIdx = 0;batchIdx<batchsize;batchIdx++){
50 58 printf("index:%d,confidence:%f\n",results[batchIdx].index,results[batchIdx].score);
  59 + vec_result.push_back(results[batchIdx].index);
51 60 }
52 61 } while (0);
53 62  
54   - if (results) {
55   - delete [] results;
56   - }
57   -
58   - return ret;
  63 + return vec_result;
59 64 }
60 65  
61 66 int MotorRainshedAnalysis::release() {
... ...
src/ai_engine_module/MotorRainshedAnalysis.h
... ... @@ -8,7 +8,7 @@ public:
8 8  
9 9 int init(int devId);
10 10  
11   - int detect(vector<sy_img> vec_img);
  11 + vector<int> detect(vector<sy_img> vec_img);
12 12  
13 13 private:
14 14 int release();
... ...