ShiqiYu / libfacedetection

An open source library for face detection in images. The face detection speed can reach 1000FPS.
Other
12.33k stars 3.05k forks source link

Problem in opencv_dnn/cpp/priorbox.cpp #311

Closed Libero-zz closed 3 years ago

Libero-zz commented 3 years ago

According to annotation and dataset code in libfacedetection.train, shouldn't 104:114 in opencv_dnn/cpp/priorbox.cpp be

// get landmarks, loc->[right_eye, left_eye, mouth_left, nose, mouth_right]
float x_le = (priors[i].center.x + loc_v[i*14+ 4] * variance[0] * priors[i].w) * out_w;
float y_le = (priors[i].center.y + loc_v[i*14+ 5] * variance[0] * priors[i].h) * out_h;
float x_re = (priors[i].center.x + loc_v[i*14+ 6] * variance[0] * priors[i].w) * out_w;
float y_re = (priors[i].center.y + loc_v[i*14+ 7] * variance[0] * priors[i].h) * out_h;
float x_n = (priors[i].center.x + loc_v[i*14+ 8] * variance[0] * priors[i].w) * out_w;
float y_n = (priors[i].center.y + loc_v[i*14+ 9] * variance[0] * priors[i].h) * out_h;
float x_ml  = (priors[i].center.x + loc_v[i*14+10] * variance[0] * priors[i].w) * out_w;
float y_ml  = (priors[i].center.y + loc_v[i*14+11] * variance[0] * priors[i].h) * out_h;
float x_mr = (priors[i].center.x + loc_v[i*14+12] * variance[0] * priors[i].w) * out_w;
float y_mr = (priors[i].center.y + loc_v[i*14+13] * variance[0] * priors[i].h) * out_h;

instead of

// get landmarks, loc->[right_eye, left_eye, mouth_left, nose, mouth_right]
float x_re = (priors[i].center.x + loc_v[i*14+ 4] * variance[0] * priors[i].w) * out_w;
float y_re = (priors[i].center.y + loc_v[i*14+ 5] * variance[0] * priors[i].h) * out_h;
float x_le = (priors[i].center.x + loc_v[i*14+ 6] * variance[0] * priors[i].w) * out_w;
float y_le = (priors[i].center.y + loc_v[i*14+ 7] * variance[0] * priors[i].h) * out_h;
float x_ml = (priors[i].center.x + loc_v[i*14+ 8] * variance[0] * priors[i].w) * out_w;
float y_ml = (priors[i].center.y + loc_v[i*14+ 9] * variance[0] * priors[i].h) * out_h;
float x_n  = (priors[i].center.x + loc_v[i*14+10] * variance[0] * priors[i].w) * out_w;
float y_n  = (priors[i].center.y + loc_v[i*14+11] * variance[0] * priors[i].h) * out_h;
float x_mr = (priors[i].center.x + loc_v[i*14+12] * variance[0] * priors[i].w) * out_w;
float y_mr = (priors[i].center.y + loc_v[i*14+13] * variance[0] * priors[i].h) * out_h;

?

fengyuentau commented 3 years ago

Thanks for your feedback. I have corrected it. The correct order to retrieve landmarks is:

right eye: loc[i*14 + 4], loc[i*14 + 5]
left eye: loc[i*14 + 6], loc[i*14 + 7]
nose tip: loc[i*14 + 8], loc[i*14 + 9]
mouth right: loc[i*14 + 10], loc[i*14 + 11]
mouth left: loc[i*14 + 12], loc[i*14 + 13]

And I also make the landmark colors in opencv_dnn the same with non opencv_dnn.