Made some thresholds dynamic.

This commit is contained in:
Daniel
2025-03-25 10:26:09 +01:00
parent fa0a4da72d
commit 71968d06fd
3 changed files with 152 additions and 149 deletions

View File

@ -294,91 +294,91 @@ Results of the model in various experiments on different datasets. \
```json ```json
{ {
"img_loading": 0.042184, "img_loading": 0.0422866,
"demosaicing": 0.000678806, "demosaicing": 0.000699368,
"avg_time_2d": 0.0147901, "avg_time_2d": 0.014883,
"avg_time_3d": 0.000119385, "avg_time_3d": 0.00011746,
"fps": 64.1505 "fps": 63.6951
} }
{ {
"triangulator_calls": 301, "triangulator_calls": 301,
"init_time": 2.93031e-06, "init_time": 2.91101e-06,
"undistort_time": 1.43119e-05, "undistort_time": 1.43844e-05,
"project_time": 2.3093e-06, "project_time": 2.16363e-06,
"match_time": 8.56559e-06, "match_time": 8.39535e-06,
"pairs_time": 4.58829e-06, "pairs_time": 4.6119e-06,
"pair_scoring_time": 2.63603e-05, "pair_scoring_time": 2.70302e-05,
"grouping_time": 4.53817e-06, "grouping_time": 4.49531e-06,
"full_time": 2.74936e-05, "full_time": 2.73468e-05,
"merge_time": 1.15484e-05, "merge_time": 1.2003e-05,
"post_time": 6.9437e-06, "post_time": 5.09957e-06,
"convert_time": 1.26757e-07, "convert_time": 1.25462e-07,
"total_time": 0.000109953 "total_time": 0.000108806
} }
{ {
"person_nums": { "person_nums": {
"total_frames": 301, "total_frames": 301,
"total_labels": 477, "total_labels": 477,
"total_preds": 832, "total_preds": 827,
"considered_empty": 0, "considered_empty": 0,
"valid_preds": 477, "valid_preds": 477,
"invalid_preds": 355, "invalid_preds": 350,
"missing": 0, "missing": 0,
"invalid_fraction": 0.42668, "invalid_fraction": 0.42322,
"precision": 0.57332, "precision": 0.57678,
"recall": 1.0, "recall": 1.0,
"f1": 0.7288, "f1": 0.7316,
"non_empty": 832 "non_empty": 827
}, },
"mpjpe": { "mpjpe": {
"count": 477, "count": 477,
"mean": 0.047771, "mean": 0.047577,
"median": 0.04252, "median": 0.042522,
"std": 0.014668, "std": 0.014987,
"sem": 0.000672, "sem": 0.000687,
"min": 0.029325, "min": 0.028778,
"max": 0.105412, "max": 0.118939,
"recall-0.025": 0.0, "recall-0.025": 0.0,
"recall-0.05": 0.702306, "recall-0.05": 0.72327,
"recall-0.1": 0.987421, "recall-0.1": 0.987421,
"recall-0.15": 1.0, "recall-0.15": 1.0,
"recall-0.25": 1.0, "recall-0.25": 1.0,
"recall-0.5": 1.0, "recall-0.5": 1.0,
"num_labels": 477, "num_labels": 477,
"ap-0.025": 0.0, "ap-0.025": 0.0,
"ap-0.05": 0.429122, "ap-0.05": 0.45527,
"ap-0.1": 0.750799, "ap-0.1": 0.751931,
"ap-0.15": 0.760584, "ap-0.15": 0.761005,
"ap-0.25": 0.760584, "ap-0.25": 0.761005,
"ap-0.5": 0.760584 "ap-0.5": 0.761005
}, },
"head": { "head": {
"count": 477, "count": 477,
"mean": 0.053874, "mean": 0.052991,
"median": 0.04981, "median": 0.048986,
"std": 0.024502, "std": 0.025142,
"sem": 0.001123, "sem": 0.001152,
"min": 0.005023, "min": 0.006559,
"max": 0.171118, "max": 0.183673,
"recall-0.025": 0.090147, "recall-0.025": 0.106918,
"recall-0.05": 0.505241, "recall-0.05": 0.522013,
"recall-0.1": 0.939203, "recall-0.1": 0.937107,
"recall-0.15": 0.997904, "recall-0.15": 0.993711,
"recall-0.25": 1.0, "recall-0.25": 1.0,
"recall-0.5": 1.0, "recall-0.5": 1.0,
"num_labels": 477 "num_labels": 477
}, },
"shoulder_left": { "shoulder_left": {
"count": 477, "count": 477,
"mean": 0.042207, "mean": 0.041956,
"median": 0.036661, "median": 0.037041,
"std": 0.020587, "std": 0.02074,
"sem": 0.000944, "sem": 0.000951,
"min": 0.004368, "min": 0.004368,
"max": 0.136632, "max": 0.132918,
"recall-0.025": 0.165618, "recall-0.025": 0.174004,
"recall-0.05": 0.740042, "recall-0.05": 0.754717,
"recall-0.1": 0.983229, "recall-0.1": 0.985325,
"recall-0.15": 1.0, "recall-0.15": 1.0,
"recall-0.25": 1.0, "recall-0.25": 1.0,
"recall-0.5": 1.0, "recall-0.5": 1.0,
@ -386,14 +386,14 @@ Results of the model in various experiments on different datasets. \
}, },
"shoulder_right": { "shoulder_right": {
"count": 477, "count": 477,
"mean": 0.049707, "mean": 0.049604,
"median": 0.046776, "median": 0.046469,
"std": 0.022703, "std": 0.022881,
"sem": 0.001041, "sem": 0.001049,
"min": 0.005334, "min": 0.005334,
"max": 0.149673, "max": 0.148157,
"recall-0.025": 0.096436, "recall-0.025": 0.100629,
"recall-0.05": 0.551363, "recall-0.05": 0.561845,
"recall-0.1": 0.955975, "recall-0.1": 0.955975,
"recall-0.15": 1.0, "recall-0.15": 1.0,
"recall-0.25": 1.0, "recall-0.25": 1.0,
@ -402,15 +402,15 @@ Results of the model in various experiments on different datasets. \
}, },
"elbow_left": { "elbow_left": {
"count": 477, "count": 477,
"mean": 0.040814, "mean": 0.040574,
"median": 0.032286, "median": 0.03197,
"std": 0.029281, "std": 0.028864,
"sem": 0.001342, "sem": 0.001323,
"min": 0.003459, "min": 0.003618,
"max": 0.309844, "max": 0.309844,
"recall-0.025": 0.318658, "recall-0.025": 0.312369,
"recall-0.05": 0.748428, "recall-0.05": 0.754717,
"recall-0.1": 0.951782, "recall-0.1": 0.953878,
"recall-0.15": 0.997904, "recall-0.15": 0.997904,
"recall-0.25": 0.997904, "recall-0.25": 0.997904,
"recall-0.5": 1.0, "recall-0.5": 1.0,
@ -418,31 +418,31 @@ Results of the model in various experiments on different datasets. \
}, },
"elbow_right": { "elbow_right": {
"count": 477, "count": 477,
"mean": 0.053474, "mean": 0.053198,
"median": 0.045174, "median": 0.043315,
"std": 0.040287, "std": 0.040536,
"sem": 0.001847, "sem": 0.001858,
"min": 0.00327, "min": 0.003567,
"max": 0.244516, "max": 0.242994,
"recall-0.025": 0.253669, "recall-0.025": 0.27044,
"recall-0.05": 0.553459, "recall-0.05": 0.563941,
"recall-0.1": 0.903564, "recall-0.1": 0.897275,
"recall-0.15": 0.960168, "recall-0.15": 0.962264,
"recall-0.25": 1.0, "recall-0.25": 1.0,
"recall-0.5": 1.0, "recall-0.5": 1.0,
"num_labels": 477 "num_labels": 477
}, },
"wrist_left": { "wrist_left": {
"count": 477, "count": 477,
"mean": 0.060043, "mean": 0.059301,
"median": 0.054688, "median": 0.054034,
"std": 0.038061, "std": 0.038637,
"sem": 0.001745, "sem": 0.001771,
"min": 0.00164, "min": 0.00164,
"max": 0.323995, "max": 0.32449,
"recall-0.025": 0.134172, "recall-0.025": 0.146751,
"recall-0.05": 0.396226, "recall-0.05": 0.412998,
"recall-0.1": 0.907757, "recall-0.1": 0.909853,
"recall-0.15": 0.964361, "recall-0.15": 0.964361,
"recall-0.25": 0.991614, "recall-0.25": 0.991614,
"recall-0.5": 1.0, "recall-0.5": 1.0,
@ -450,47 +450,47 @@ Results of the model in various experiments on different datasets. \
}, },
"wrist_right": { "wrist_right": {
"count": 477, "count": 477,
"mean": 0.058016, "mean": 0.058286,
"median": 0.054634, "median": 0.053472,
"std": 0.030706, "std": 0.034178,
"sem": 0.001407, "sem": 0.001567,
"min": 0.008622, "min": 0.008622,
"max": 0.238817, "max": 0.382984,
"recall-0.025": 0.111111, "recall-0.025": 0.113208,
"recall-0.05": 0.421384, "recall-0.05": 0.440252,
"recall-0.1": 0.903564, "recall-0.1": 0.90566,
"recall-0.15": 0.985325, "recall-0.15": 0.981132,
"recall-0.25": 1.0, "recall-0.25": 0.997904,
"recall-0.5": 1.0, "recall-0.5": 1.0,
"num_labels": 477 "num_labels": 477
}, },
"hip_left": { "hip_left": {
"count": 477, "count": 477,
"mean": 0.048043, "mean": 0.047666,
"median": 0.042435, "median": 0.042435,
"std": 0.025895, "std": 0.025966,
"sem": 0.001187, "sem": 0.00119,
"min": 0.006314, "min": 0.008125,
"max": 0.173228, "max": 0.145941,
"recall-0.025": 0.159329, "recall-0.025": 0.188679,
"recall-0.05": 0.624738, "recall-0.05": 0.628931,
"recall-0.1": 0.955975, "recall-0.1": 0.958071,
"recall-0.15": 0.997904, "recall-0.15": 1.0,
"recall-0.25": 1.0, "recall-0.25": 1.0,
"recall-0.5": 1.0, "recall-0.5": 1.0,
"num_labels": 477 "num_labels": 477
}, },
"hip_right": { "hip_right": {
"count": 477, "count": 477,
"mean": 0.057878, "mean": 0.057617,
"median": 0.056579, "median": 0.058504,
"std": 0.023899, "std": 0.023884,
"sem": 0.001095, "sem": 0.001095,
"min": 0.006301, "min": 0.006301,
"max": 0.132422, "max": 0.132422,
"recall-0.025": 0.098532, "recall-0.025": 0.102725,
"recall-0.05": 0.352201, "recall-0.05": 0.354298,
"recall-0.1": 0.9413, "recall-0.1": 0.943396,
"recall-0.15": 1.0, "recall-0.15": 1.0,
"recall-0.25": 1.0, "recall-0.25": 1.0,
"recall-0.5": 1.0, "recall-0.5": 1.0,
@ -498,15 +498,15 @@ Results of the model in various experiments on different datasets. \
}, },
"knee_left": { "knee_left": {
"count": 477, "count": 477,
"mean": 0.040068, "mean": 0.040292,
"median": 0.036879, "median": 0.037394,
"std": 0.02442, "std": 0.024591,
"sem": 0.001119, "sem": 0.001127,
"min": 0.005242, "min": 0.00468,
"max": 0.190112, "max": 0.190112,
"recall-0.025": 0.257862, "recall-0.025": 0.264151,
"recall-0.05": 0.754717, "recall-0.05": 0.752621,
"recall-0.1": 0.974843, "recall-0.1": 0.972746,
"recall-0.15": 0.989518, "recall-0.15": 0.989518,
"recall-0.25": 1.0, "recall-0.25": 1.0,
"recall-0.5": 1.0, "recall-0.5": 1.0,
@ -514,14 +514,14 @@ Results of the model in various experiments on different datasets. \
}, },
"knee_right": { "knee_right": {
"count": 477, "count": 477,
"mean": 0.039748, "mean": 0.039685,
"median": 0.035762, "median": 0.035562,
"std": 0.023, "std": 0.023057,
"sem": 0.001054, "sem": 0.001057,
"min": 0.007276, "min": 0.005833,
"max": 0.184978, "max": 0.184978,
"recall-0.025": 0.316562, "recall-0.025": 0.318658,
"recall-0.05": 0.72956, "recall-0.05": 0.735849,
"recall-0.1": 0.974843, "recall-0.1": 0.974843,
"recall-0.15": 0.997904, "recall-0.15": 0.997904,
"recall-0.25": 1.0, "recall-0.25": 1.0,
@ -530,13 +530,13 @@ Results of the model in various experiments on different datasets. \
}, },
"ankle_left": { "ankle_left": {
"count": 477, "count": 477,
"mean": 0.036387, "mean": 0.036424,
"median": 0.028113, "median": 0.027617,
"std": 0.030604, "std": 0.030554,
"sem": 0.001403, "sem": 0.0014,
"min": 0.004893, "min": 0.004893,
"max": 0.223793, "max": 0.223793,
"recall-0.025": 0.429769, "recall-0.025": 0.42348,
"recall-0.05": 0.819706, "recall-0.05": 0.819706,
"recall-0.1": 0.947589, "recall-0.1": 0.947589,
"recall-0.15": 0.983229, "recall-0.15": 0.983229,
@ -546,14 +546,14 @@ Results of the model in various experiments on different datasets. \
}, },
"ankle_right": { "ankle_right": {
"count": 477, "count": 477,
"mean": 0.040761, "mean": 0.040909,
"median": 0.030879, "median": 0.030845,
"std": 0.037437, "std": 0.037585,
"sem": 0.001716, "sem": 0.001723,
"min": 0.003316, "min": 0.003445,
"max": 0.28852, "max": 0.28852,
"recall-0.025": 0.301887, "recall-0.025": 0.301887,
"recall-0.05": 0.809224, "recall-0.05": 0.807128,
"recall-0.1": 0.930818, "recall-0.1": 0.930818,
"recall-0.15": 0.968553, "recall-0.15": 0.968553,
"recall-0.25": 0.997904, "recall-0.25": 0.997904,
@ -562,18 +562,18 @@ Results of the model in various experiments on different datasets. \
}, },
"joint_recalls": { "joint_recalls": {
"num_labels": 6201, "num_labels": 6201,
"recall-0.025": 0.20916, "recall-0.025": 0.21609,
"recall-0.05": 0.6149, "recall-0.05": 0.62329,
"recall-0.1": 0.94356, "recall-0.1": 0.94291,
"recall-0.15": 0.98774, "recall-0.15": 0.9871,
"recall-0.25": 0.99887, "recall-0.25": 0.99871,
"recall-0.5": 1.0 "recall-0.5": 1.0
} }
} }
{ {
"total_parts": 6678, "total_parts": 6678,
"correct_parts": 6621, "correct_parts": 6623,
"pcp": 0.991465 "pcp": 0.991764
} }
``` ```

View File

@ -525,6 +525,7 @@ std::vector<std::vector<std::array<float, 4>>> TriangulatorInternal::triangulate
} }
// Convert inputs to internal formats // Convert inputs to internal formats
this->num_cams = cameras.size();
std::vector<std::vector<std::vector<std::array<float, 3>>>> i_poses_2d = poses_2d; std::vector<std::vector<std::vector<std::array<float, 3>>>> i_poses_2d = poses_2d;
std::vector<CameraInternal> internal_cameras; std::vector<CameraInternal> internal_cameras;
for (size_t i = 0; i < cameras.size(); ++i) for (size_t i = 0; i < cameras.size(); ++i)
@ -1809,6 +1810,7 @@ std::vector<std::array<float, 4>> TriangulatorInternal::merge_group(
// Use only those triangulations with a high score // Use only those triangulations with a high score
std::vector<std::array<float, 4>> sum_poses(num_joints, {0.0, 0.0, 0.0, 0.0}); std::vector<std::array<float, 4>> sum_poses(num_joints, {0.0, 0.0, 0.0, 0.0});
std::vector<float> sum_mask1(num_joints, 0); std::vector<float> sum_mask1(num_joints, 0);
float offset1 = (1.0 - min_score) / 2.0;
for (size_t i = 0; i < num_poses; ++i) for (size_t i = 0; i < num_poses; ++i)
{ {
const auto &pose = poses_3d[i]; const auto &pose = poses_3d[i];
@ -1816,7 +1818,7 @@ std::vector<std::array<float, 4>> TriangulatorInternal::merge_group(
for (size_t j = 0; j < num_joints; ++j) for (size_t j = 0; j < num_joints; ++j)
{ {
float score = pose[j][3]; float score = pose[j][3];
if (score > min_score) if (score > min_score - offset1)
{ {
float weight = std::pow(score, 2); float weight = std::pow(score, 2);
sum_poses[j][0] += pose[j][0] * weight; sum_poses[j][0] += pose[j][0] * weight;
@ -1847,7 +1849,7 @@ std::vector<std::array<float, 4>> TriangulatorInternal::merge_group(
for (size_t j = 0; j < num_joints; ++j) for (size_t j = 0; j < num_joints; ++j)
{ {
float score = initial_pose_3d[j][3]; float score = initial_pose_3d[j][3];
if (score > min_score) if (score > min_score - offset1)
{ {
jmask[j] = true; jmask[j] = true;
center[0] += initial_pose_3d[j][0]; center[0] += initial_pose_3d[j][0];
@ -1875,7 +1877,7 @@ std::vector<std::array<float, 4>> TriangulatorInternal::merge_group(
} }
// Drop joints with low scores and filter outlying joints using distance threshold // Drop joints with low scores and filter outlying joints using distance threshold
float offset = 0.1; float offset2 = (1.0 - min_score) * 2.0;
float max_dist_sq = 1.2 * 1.2; float max_dist_sq = 1.2 * 1.2;
std::vector<std::vector<bool>> mask(num_poses, std::vector<bool>(num_joints, false)); std::vector<std::vector<bool>> mask(num_poses, std::vector<bool>(num_joints, false));
std::vector<std::vector<float>> distances(num_poses, std::vector<float>(num_joints, 0.0)); std::vector<std::vector<float>> distances(num_poses, std::vector<float>(num_joints, 0.0));
@ -1891,7 +1893,7 @@ std::vector<std::array<float, 4>> TriangulatorInternal::merge_group(
distances[i][j] = dist_sq; distances[i][j] = dist_sq;
float score = pose[j][3]; float score = pose[j][3];
if (dist_sq <= max_dist_sq && score > (min_score - offset)) if (dist_sq <= max_dist_sq && score > (min_score - offset2))
{ {
mask[i][j] = true; mask[i][j] = true;
} }
@ -1899,7 +1901,7 @@ std::vector<std::array<float, 4>> TriangulatorInternal::merge_group(
} }
// Select the best-k proposals for each joint that are closest to the initial pose // Select the best-k proposals for each joint that are closest to the initial pose
int keep_best = std::max(3, (int)num_poses / 3); int keep_best = std::max((int)std::ceil(this->num_cams / 2.0), (int)std::ceil(num_poses / 3.0));
std::vector<std::vector<bool>> best_k_mask(num_poses, std::vector<bool>(num_joints, false)); std::vector<std::vector<bool>> best_k_mask(num_poses, std::vector<bool>(num_joints, false));
for (size_t j = 0; j < num_joints; ++j) for (size_t j = 0; j < num_joints; ++j)
{ {

View File

@ -54,6 +54,7 @@ public:
private: private:
float min_match_score; float min_match_score;
float min_group_size; float min_group_size;
size_t num_cams;
const std::vector<std::string> core_joints = { const std::vector<std::string> core_joints = {
"shoulder_left", "shoulder_left",