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

alignment(src_img, src_pts) function ? #50

Open
Ontheway361 opened this issue Dec 17, 2019 · 2 comments
Open

alignment(src_img, src_pts) function ? #50

Ontheway361 opened this issue Dec 17, 2019 · 2 comments

Comments

@Ontheway361
Copy link

def alignment(src_img,src_pts):
of = 2
ref_pts = [ [30.2946+of, 51.6963+of],[65.5318+of, 51.5014+of],
[48.0252+of, 71.7366+of],[33.5493+of, 92.3655+of],[62.7299+of, 92.2041+of] ]
crop_size = (96+of2, 112+of2)

s = np.array(src_pts).astype(np.float32)
r = np.array(ref_pts).astype(np.float32)

tfm = get_similarity_transform_for_cv2(s, r)
face_img = cv2.warpAffine(src_img, tfm, crop_size)
return face_img

Is there any information or reason for the fixed ref_pts ? why we picked those values ?

@Ontheway361
Copy link
Author

I wonder ref_pts was calculated by following way:
step -1. ave_pts = np.mean(all_landmarks_in_casia, axis=0), where all_landmarks_in_casia.shape=(N, 10);
step -2. norm_pts = ave_pts / 250, where casia_img.shape = (250, 250)
step -3. ref_pts = norm_pts.reshape(-1, 2) * np.array([96, 112])
Then, we can get following result:
array([[37.4707173 , 48.19678096],
[57.53267604, 47.69648029],
[47.40494149, 63.3143305 ],
[38.90172655, 74.50723587],
[56.77106886, 74.12000792]])
Absolutely, It was different with the ref_pts in which alignment function region.

@Ontheway361
Copy link
Author

@clcarwin, Looking forward to your reply!

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

1 participant