Skip to content

Face Alignment #14

@anguoyang

Description

@anguoyang

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;

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions