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

Face Alignment #14

Open
anguoyang opened this issue Mar 8, 2018 · 2 comments
Open

Face Alignment #14

anguoyang opened this issue Mar 8, 2018 · 2 comments

Comments

@anguoyang
Copy link

Hi@tpys , you align the face image into 112x96, however,I need to align it into 112x112(insight face, which is similar with sphereface), so I simply changed the ReferenceWidth and ReferenceHeight into 112/112, but it seems that the aligned face is not correct(cut so much area), so it is not as accurate as InsightFace
, maybe the problem is the ReferenceIDs, could you please tell me how to get the reference Points for 112x112 image? thank you.


cv::Mat align_face(const cv::Mat& src, const FaceLandmark& landmark, int width, int height) {

const int N = landmark.points_.size();
vector<cv::Point2f> detect_points;
if (N != 5) {
	detect_points = {
		landmark.points_[ReferenceID[0]],
		landmark.points_[ReferenceID[1]],
		landmark.points_[ReferenceID[2]],
		landmark.points_[ReferenceID[3]],
		landmark.points_[ReferenceID[4]],
	};
}
else {
	detect_points = landmark.points_;
}

const int ReferenceWidth = 112;
const int ReferenceHeight = 112;

**vectorcv::Point2f reference_points = {

	{ 30.29459953f,  51.69630051f },
	{ 65.53179932f,  51.50139999f },
	{ 48.02519989f,  71.73660278f },
	{ 33.54930115f,  92.3655014f },
	{ 62.72990036f,  92.20410156f }
};**
for (auto& e : reference_points) {
	e.x += (width - ReferenceWidth) / 2.0f;
	e.y += (height - ReferenceHeight) / 2.0f;
}
cv::Mat tfm = get_similarity_transform(detect_points, reference_points);
cv::Mat aligned_face;
warpAffine(src, aligned_face, tfm, cv::Size(width, height));
return aligned_face;

}

@lzg188
Copy link

lzg188 commented Apr 17, 2018

if (ReferenceWidth == 112)
wex = 8;
vector reference_points = {
Point2f( 30.29459953+wex, 51.69630051 ),
Point2f( 65.53179932+wex, 51.50139999 ),
Point2f( 48.02519989 + wex, 71.73660278 ),
Point2f( 33.54930115 + wex, 92.3655014 ),
Point2f( 62.72990036 + wex, 92.20410156 )
};

@anguoyang
Copy link
Author

@lzg188 thank you so much!

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

2 participants