| 983 | } |
| 984 | |
| 985 | int connectLimbs( |
| 986 | std::vector< std::vector<double>> &subset, |
| 987 | std::vector< std::vector< std::vector<double> > > &connection, |
| 988 | const float *heatmap_pointer, |
| 989 | const float *peaks, |
| 990 | int max_peaks, |
| 991 | float *joints, |
| 992 | ModelDescriptor *model_descriptor) { |
| 993 | |
| 994 | const auto num_parts = model_descriptor->get_number_parts(); |
| 995 | const auto limbSeq = model_descriptor->get_limb_sequence(); |
| 996 | const auto mapIdx = model_descriptor->get_map_idx(); |
| 997 | const auto number_limb_seq = model_descriptor->number_limb_sequence(); |
| 998 | |
| 999 | int SUBSET_CNT = num_parts+2; |
| 1000 | int SUBSET_SCORE = num_parts+1; |
| 1001 | int SUBSET_SIZE = num_parts+3; |
| 1002 | |
| 1003 | CHECK_EQ(num_parts, 15); |
| 1004 | CHECK_EQ(number_limb_seq, 14); |
| 1005 | |
| 1006 | int peaks_offset = 3*(max_peaks+1); |
| 1007 | subset.clear(); |
| 1008 | connection.clear(); |
| 1009 | |
| 1010 | for(int k = 0; k < number_limb_seq; k++) { |
| 1011 | const float* map_x = heatmap_pointer + mapIdx[2*k] * NET_RESOLUTION_HEIGHT |
| 1012 | * NET_RESOLUTION_WIDTH; |
| 1013 | const float* map_y = heatmap_pointer + mapIdx[2*k+1] * NET_RESOLUTION_HEIGHT |
| 1014 | * NET_RESOLUTION_WIDTH; |
| 1015 | |
| 1016 | const float* candA = peaks + limbSeq[2*k]*peaks_offset; |
| 1017 | const float* candB = peaks + limbSeq[2*k+1]*peaks_offset; |
| 1018 | |
| 1019 | std::vector< std::vector<double> > connection_k; |
| 1020 | int nA = candA[0]; |
| 1021 | int nB = candB[0]; |
| 1022 | |
| 1023 | // add parts into the subset in special case |
| 1024 | if (nA ==0 && nB ==0) { |
| 1025 | continue; |
| 1026 | } |
| 1027 | else if (nA ==0) { |
| 1028 | for(int i = 1; i <= nB; i++) { |
| 1029 | std::vector<double> row_vec(SUBSET_SIZE, 0); |
| 1030 | row_vec[ limbSeq[2*k+1] ] = limbSeq[2*k+1]*peaks_offset + i*3 + 2; |
| 1031 | row_vec[SUBSET_CNT] = 1; //last number in each row is the parts number |
| 1032 | //of that person |
| 1033 | row_vec[SUBSET_SCORE] = candB[i*3+2]; //second last number in each row |
| 1034 | //is the total score |
| 1035 | subset.push_back(row_vec); |
| 1036 | } |
| 1037 | continue; |
| 1038 | } |
| 1039 | else if (nB ==0) { |
| 1040 | for(int i = 1; i <= nA; i++) { |
| 1041 | std::vector<double> row_vec(SUBSET_SIZE, 0); |
| 1042 | row_vec[ limbSeq[2*k] ] = limbSeq[2*k]*peaks_offset + i*3 + 2;//store |
no test coverage detected