MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / distanceThresholdPeaks

Function distanceThresholdPeaks

rtpose_wrapper/apps/rtpose.cpp:1203–1257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1201}
1202
1203int distanceThresholdPeaks(const float *in_peaks, int max_peaks,
1204 float *peaks, ModelDescriptor *model_descriptor) {
1205 // Post-process peaks to remove those which are within sqrt(dist_threshold2)
1206 // of each other.
1207
1208 const auto num_parts = model_descriptor->get_number_parts();
1209 const float dist_threshold2 = 6*6;
1210 int peaks_offset = 3*(max_peaks+1);
1211
1212 int total_peaks = 0;
1213 for(int p = 0; p < num_parts; p++) {
1214 const float *pipeaks = in_peaks + p*peaks_offset;
1215 float *popeaks = peaks + p*peaks_offset;
1216 int num_in_peaks = int(pipeaks[0]);
1217 int num_out_peaks = 0; // Actual number of peak count
1218 for (int c1=0;c1<num_in_peaks;c1++) {
1219 float x1 = pipeaks[(c1+1)*3+0];
1220 float y1 = pipeaks[(c1+1)*3+1];
1221 float s1 = pipeaks[(c1+1)*3+2];
1222 bool keep = true;
1223 for (int c2=0;c2<num_out_peaks;c2++) {
1224 float x2 = popeaks[(c2+1)*3+0];
1225 float y2 = popeaks[(c2+1)*3+1];
1226 float s2 = popeaks[(c2+1)*3+2];
1227 float dist2 = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
1228 if (dist2<dist_threshold2) {
1229 // This peak is too close to a peak already in the output buffer
1230 // so don't add it.
1231 keep = false;
1232 if (s1>s2) {
1233 // It's better than the one in the output buffer
1234 // so we swap it.
1235 popeaks[(c2+1)*3+0] = x1;
1236 popeaks[(c2+1)*3+1] = y1;
1237 popeaks[(c2+1)*3+2] = s1;
1238 }
1239 }
1240 }
1241 if (keep && num_out_peaks<max_peaks) {
1242 // We don't already have a better peak within the threshold distance
1243 popeaks[(num_out_peaks+1)*3+0] = x1;
1244 popeaks[(num_out_peaks+1)*3+1] = y1;
1245 popeaks[(num_out_peaks+1)*3+2] = s1;
1246 num_out_peaks++;
1247 }
1248 }
1249 // if (num_in_peaks!=num_out_peaks) {
1250 //LOG(INFO) << "Part: " << p << " in peaks: "<< num_in_peaks << " out: "
1251 //<< num_out_peaks;
1252 // }
1253 popeaks[0] = float(num_out_peaks);
1254 total_peaks += num_out_peaks;
1255 }
1256 return total_peaks;
1257}
1258
1259int connectLimbsCOCO(
1260 std::vector< std::vector<double>> &subset,

Callers

nothing calls this directly

Calls 1

get_number_partsMethod · 0.80

Tested by

no test coverage detected