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

View File

@ -525,6 +525,7 @@ std::vector<std::vector<std::array<float, 4>>> TriangulatorInternal::triangulate
}
// 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<CameraInternal> internal_cameras;
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
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);
float offset1 = (1.0 - min_score) / 2.0;
for (size_t i = 0; i < num_poses; ++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)
{
float score = pose[j][3];
if (score > min_score)
if (score > min_score - offset1)
{
float weight = std::pow(score, 2);
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)
{
float score = initial_pose_3d[j][3];
if (score > min_score)
if (score > min_score - offset1)
{
jmask[j] = true;
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
float offset = 0.1;
float offset2 = (1.0 - min_score) * 2.0;
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<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;
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;
}
@ -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
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));
for (size_t j = 0; j < num_joints; ++j)
{

View File

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