Commit 667e7a901ce4e1aa715a09d37ef9b6fba1093870
1 parent
b3012672
雨棚和打电话初步代码
Showing
5 changed files
with
68 additions
and
42 deletions
src/PicAnalysis.cpp
@@ -22,13 +22,13 @@ int PicAnalysis::init(int dev_id) { | @@ -22,13 +22,13 @@ int PicAnalysis::init(int dev_id) { | ||
22 | return -1; | 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 | ret = m_clothes_algorithm.init(dev_id); | 33 | ret = m_clothes_algorithm.init(dev_id); |
34 | if(0 != ret){ | 34 | if(0 != ret){ |
@@ -119,7 +119,7 @@ int PicAnalysis::analysis_sync(vector<string> vec_file_path){ | @@ -119,7 +119,7 @@ int PicAnalysis::analysis_sync(vector<string> vec_file_path){ | ||
119 | ImageData src = dvpp_data[b]; | 119 | ImageData src = dvpp_data[b]; |
120 | for(int c=0;c<result[b].count;c++) | 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 | int shot_type=result[b].info[c].type; | 123 | int shot_type=result[b].info[c].type; |
124 | 124 | ||
125 | // 行人 | 125 | // 行人 |
@@ -140,6 +140,19 @@ int PicAnalysis::analysis_sync(vector<string> vec_file_path){ | @@ -140,6 +140,19 @@ int PicAnalysis::analysis_sync(vector<string> vec_file_path){ | ||
140 | 140 | ||
141 | delete human_data; | 141 | delete human_data; |
142 | human_data = nullptr; | 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<string> vec_file_path){ | @@ -189,13 +202,19 @@ int PicAnalysis::analysis_sync(vector<string> vec_file_path){ | ||
189 | vector<sy_img> vec_motor_img; | 202 | vector<sy_img> vec_motor_img; |
190 | vec_motor_img.push_back(img); | 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 | delete motor_data; | 218 | delete motor_data; |
200 | motor_data = nullptr; | 219 | motor_data = nullptr; |
201 | } | 220 | } |
@@ -203,14 +222,12 @@ int PicAnalysis::analysis_sync(vector<string> vec_file_path){ | @@ -203,14 +222,12 @@ int PicAnalysis::analysis_sync(vector<string> 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 | LOG_INFO("analysis_sync finished!"); | 232 | LOG_INFO("analysis_sync finished!"); |
216 | 233 |
src/ai_engine_module/MotorPhoneAnalysis.cpp
@@ -29,18 +29,26 @@ int MotorPhoneAnalysis::init(int devId){ | @@ -29,18 +29,26 @@ int MotorPhoneAnalysis::init(int devId){ | ||
29 | return SY_SUCCESS; | 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 | const int batchsize = vec_img.size(); | 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 | int ret = SY_FAILED; | 41 | int ret = SY_FAILED; |
40 | 42 | ||
41 | do | 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 | if (SY_SUCCESS != ret) { | 52 | if (SY_SUCCESS != ret) { |
45 | printf("motor_phone_process_batch failed!"); | 53 | printf("motor_phone_process_batch failed!"); |
46 | break; | 54 | break; |
@@ -54,11 +62,7 @@ int MotorPhoneAnalysis::detect(vector<sy_img> vec_img){ | @@ -54,11 +62,7 @@ int MotorPhoneAnalysis::detect(vector<sy_img> vec_img){ | ||
54 | } | 62 | } |
55 | } while (0); | 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 | int MotorPhoneAnalysis::release() { | 68 | int MotorPhoneAnalysis::release() { |
src/ai_engine_module/MotorPhoneAnalysis.h
src/ai_engine_module/MotorRainshedAnalysis.cpp
@@ -29,33 +29,38 @@ int MotorRainshedAnalysis::init(int devId){ | @@ -29,33 +29,38 @@ int MotorRainshedAnalysis::init(int devId){ | ||
29 | return SY_SUCCESS; | 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 | const int batchsize = vec_img.size(); | 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 | int ret = SY_FAILED; | 41 | int ret = SY_FAILED; |
40 | 42 | ||
41 | do | 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 | if (SY_SUCCESS != ret) { | 52 | if (SY_SUCCESS != ret) { |
45 | printf("mrc_batch failed!"); | 53 | printf("mrc_batch failed!"); |
46 | break; | 54 | break; |
47 | } | 55 | } |
48 | 56 | ||
49 | - for(int batchIdx = 0;batchIdx<batchsize;batchIdx++){ | 57 | + for(int batchIdx = 0;batchIdx<batchsize;batchIdx++){ |
50 | printf("index:%d,confidence:%f\n",results[batchIdx].index,results[batchIdx].score); | 58 | printf("index:%d,confidence:%f\n",results[batchIdx].index,results[batchIdx].score); |
59 | + vec_result.push_back(results[batchIdx].index); | ||
51 | } | 60 | } |
52 | } while (0); | 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 | int MotorRainshedAnalysis::release() { | 66 | int MotorRainshedAnalysis::release() { |
src/ai_engine_module/MotorRainshedAnalysis.h