freesouls / face-alignment-at-3000fps

The project is an C++ implementation of Face Alignment at 3000fps via Regressing Local Binary Features
283 stars 145 forks source link

请问代码里的initial_guess和getsimilarTransform是什么意思?谢谢 #3

Open mariolew opened 8 years ago

mariolew commented 8 years ago

如题,谢谢,没有太懂。

freesouls commented 8 years ago

initial_guess是我们最开始认为的人脸关键点的位置,一般就是mean shape做最初始的guess,然后一步一步去调整各个点的位置,往关键点真正的坐标位置移动(这个词不是那么贴切),guess多一点就是增加模型的鲁棒性

getsimilarTransform, 就是我有两个shape A, shape B, 如果我从A变换到B到怎么做,这个函数就是算从A变换到B要转过多少的角度,然后缩小放大的倍数(这两步反一下也没问题)

freesouls commented 8 years ago

getsimilarTransform我有英语注释: // get the rotation and scale parameters by transferring shape_from to shape_to, shape_to = M*shape_from 其中M是一个变换矩阵,我们要算的就是M里的值

mariolew commented 8 years ago

那么在程序中getsimilarTransform函数具体有啥作用呢,是否可以直接回归delta S 而不用先Transform再Transform回来呢? 也就是说 getSimilarityTransform(params_.meanshape, ProjectShape(augmented_current_shapes[i], augmented_bboxes[i]), rotation, scale); cv::transpose(rotation, rotation); regression_targets[i] = scale * regression_targets[i] * rotation; getSimilarityTransform(ProjectShape(augmented_current_shapes[i], augmentedbboxes[i]), params.meanshape, rotation, scale); rotations[i] = rotation; scales[i] = scale; 这几句话怎么理解?

freesouls commented 8 years ago

这里2.1节讲了原因,face-alignment-at-3000fps是在这篇的基础上做的,框架一模一样

gmlyytt-YANG commented 7 years ago

@freesouls 麻烦能不能具体分析一下getSimilarityTransform 是如何进行坐标变换的,特别是下面这段代码,取自于utils.cpp的74行到92行。calcCovarMatrix输出的协方差矩阵covariance1维度是(2, 2), 而均值矩阵mean1 却是一个(68, 1)的矩阵,如果说协方差矩阵是(2, 2)的,这证明这个协方差输出的是人脸坐标点的X坐标和Y坐标的相关性,但是均值却是每个坐标点的X和Y的均值,这点实在有点想不明白。谢谢你啦。

cv::calcCovarMatrix(temp1, covariance1, mean1, cv::COVAR_COLS, CV_64F); //CV_COVAR_COLS
cv::calcCovarMatrix(temp2, covariance2, mean2, cv::COVAR_COLS, CV_64F);

double s1 = sqrt(norm(covariance1));
double s2 = sqrt(norm(covariance2));
scale = s1 / s2;
temp1 = 1.0 / s1 * temp1;
temp2 = 1.0 / s2 * temp2;

double num = 0.0;
double den = 0.0;
for (int i = 0; i < shape_to.rows; i++){
        num = num + temp1(i, 1) * temp2(i, 0) - temp1(i, 0) * temp2(i, 1);
    den = den + temp1(i, 0) * temp2(i, 0) + temp1(i, 1) * temp2(i, 1);
}

double norm = sqrt(num*num + den*den);
double sin_theta = num / norm;
double cos_theta = den / norm;
kismde commented 6 years ago

@gmlyytt-YANG ,请问你找到理论依据了吗? @freesouls 大神,能给出一个计算变换矩阵M的公式吗?