Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mariolew opened this issue Mar 9, 2016 · 6 comments

Comments

@mariolew
Copy link

mariolew commented Mar 9, 2016

如题,谢谢,没有太懂。

@freesouls
Copy link
Owner

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

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

@freesouls
Copy link
Owner

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

@mariolew
Copy link
Author

mariolew commented Mar 9, 2016

那么在程序中getsimilarTransform函数具体有啥作用呢,是否可以直接回归delta S 而不用先Transform再Transform回来呢?
也就是说
getSimilarityTransform(params_.mean_shape_, 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], augmented_bboxes[i]), params_.mean_shape_, rotation, scale);
rotations_[i] = rotation;
scales_[i] = scale;
这几句话怎么理解?

@freesouls
Copy link
Owner

freesouls commented Mar 10, 2016

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

@gmlyytt-YANG
Copy link

gmlyytt-YANG commented Sep 1, 2017

@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
Copy link

kismde commented Oct 26, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants