| 1257 | } |
| 1258 | |
| 1259 | int connectLimbsCOCO( |
| 1260 | std::vector< std::vector<double>> &subset, |
| 1261 | std::vector< std::vector< std::vector<double> > > &connection, |
| 1262 | const float *heatmap_pointer, |
| 1263 | const float *in_peaks, |
| 1264 | int max_peaks, |
| 1265 | float *joints, |
| 1266 | ModelDescriptor *model_descriptor) { |
| 1267 | /* Parts Connection ---------------------------------------*/ |
| 1268 | const auto num_parts = model_descriptor->get_number_parts(); |
| 1269 | const auto limbSeq = model_descriptor->get_limb_sequence(); |
| 1270 | const auto mapIdx = model_descriptor->get_map_idx(); |
| 1271 | const auto number_limb_seq = model_descriptor->number_limb_sequence(); |
| 1272 | |
| 1273 | CHECK_EQ(num_parts, 18) << "Wrong connection function for model"; |
| 1274 | CHECK_EQ(number_limb_seq, 19) << "Wrong connection function for model"; |
| 1275 | |
| 1276 | int SUBSET_CNT = num_parts+2; |
| 1277 | int SUBSET_SCORE = num_parts+1; |
| 1278 | int SUBSET_SIZE = num_parts+3; |
| 1279 | |
| 1280 | const int peaks_offset = 3*(max_peaks+1); |
| 1281 | |
| 1282 | const float *peaks = in_peaks; |
| 1283 | subset.clear(); |
| 1284 | connection.clear(); |
| 1285 | |
| 1286 | for(int k = 0; k < number_limb_seq; k++) { |
| 1287 | const float* map_x = heatmap_pointer + mapIdx[2*k] * NET_RESOLUTION_HEIGHT |
| 1288 | * NET_RESOLUTION_WIDTH; |
| 1289 | const float* map_y = heatmap_pointer + mapIdx[2*k+1] * NET_RESOLUTION_HEIGHT |
| 1290 | * NET_RESOLUTION_WIDTH; |
| 1291 | |
| 1292 | const float* candA = peaks + limbSeq[2*k]*peaks_offset; |
| 1293 | const float* candB = peaks + limbSeq[2*k+1]*peaks_offset; |
| 1294 | |
| 1295 | std::vector< std::vector<double> > connection_k; |
| 1296 | int nA = candA[0]; |
| 1297 | int nB = candB[0]; |
| 1298 | |
| 1299 | // add parts into the subset in special case |
| 1300 | if (nA ==0 && nB ==0) { |
| 1301 | continue; |
| 1302 | } else if (nA ==0) { |
| 1303 | for(int i = 1; i <= nB; i++) { |
| 1304 | int num = 0; |
| 1305 | int indexB = limbSeq[2*k+1]; |
| 1306 | for(int j = 0; j < subset.size(); j++) { |
| 1307 | int off = limbSeq[2*k+1]*peaks_offset + i*3 + 2; |
| 1308 | if (subset[j][indexB] == off) { |
| 1309 | num = num+1; |
| 1310 | continue; |
| 1311 | } |
| 1312 | } |
| 1313 | if (num!=0) { |
| 1314 | //LOG(INFO) << " else if (nA==0) shouldn't have any nB |
| 1315 | // already assigned?"; |
| 1316 | } else { |
no test coverage detected