1 | initial version |
time to start preliminary answers, i guess,..
1) yes, try a CascadeClassifier. if you can find out, that you can crop your images to the significant face part, you've already won something.
2) optional align to eyes. you can use another CascadeClassifier to find them, or some landmarks, like from flandmark or dlib. then, it's basically this:
double eyeXdis = eye_r.x - eye_l.x;
double eyeYdis = eye_r.y - eye_l.y;
double angle = atan(eyeYdis/eyeXdis);
double degree = angle*180/CV_PI;
double desired_eye_distance = 44.0;
double scale = desired_eye_distance / eyeXdis;
Mat res;
Point2f center(test.cols/2, test.rows/2);
Mat rot = getRotationMatrix2D(center, degree, scale);
warpAffine(test, res, rot, Size(), INTER_CUBIC, BORDER_CONSTANT, Scalar(127));
// probably crop this again from center
3) now it's time to compare the images. ofc. you can save them to disk with imwrite() and use phash on that, but while you're in opencv, might as well try some other things:
double dist = norm(a,b);
and compare to some threshold2 | No.2 Revision |
time to start preliminary answers, i guess,..
1) yes, try a CascadeClassifier. if you can find out, that you can crop your images to the significant face part, you've already won something.
2) 3) optional align to eyes. you can use another CascadeClassifier to find them, or some landmarks, like from flandmark or dlib. then, it's basically this:
double eyeXdis = eye_r.x - eye_l.x;
double eyeYdis = eye_r.y - eye_l.y;
double angle = atan(eyeYdis/eyeXdis);
double degree = angle*180/CV_PI;
double desired_eye_distance = 44.0;
double scale = desired_eye_distance / eyeXdis;
Mat res;
Point2f center(test.cols/2, test.rows/2);
Mat rot = getRotationMatrix2D(center, degree, scale);
warpAffine(test, res, rot, Size(), INTER_CUBIC, BORDER_CONSTANT, Scalar(127));
// probably crop this again from center
3) 4) now it's time to compare the images. ofc. you can save them to disk with imwrite() and use phash on that, but while you're in opencv, might as well try some other things:
double dist = norm(a,b);
and compare to some threshold3 | No.3 Revision |
time to start preliminary answers, i guess,..
1) yes, try a CascadeClassifier. if you can find out, that you can crop your images to the significant face part, you've already won something.
2) 3) optional align to eyes. you can use another CascadeClassifier to find them, or some landmarks, like from flandmark or dlib. then, it's basically this:
double eyeXdis = eye_r.x - eye_l.x;
double eyeYdis = eye_r.y - eye_l.y;
double angle = atan(eyeYdis/eyeXdis);
double degree = angle*180/CV_PI;
double desired_eye_distance = 44.0;
double scale = desired_eye_distance / eyeXdis;
Mat res;
Point2f center(test.cols/2, test.rows/2);
Mat rot = getRotationMatrix2D(center, degree, scale);
warpAffine(test, res, rot, Size(), INTER_CUBIC, BORDER_CONSTANT, Scalar(127));
// probably crop this again from center
4) now it's time to compare the images. ofc. you can save them to disk with imwrite() and use phash on that, but while you're in opencv, might as well try some other things:
double dist = norm(a,b);
and compare to some threshold4 | No.4 Revision |
time to start preliminary answers, i guess,..
1) yes, try a CascadeClassifier. if you can find out, that you can crop your images to the significant face part, you've already won something.
2) 3) optional align to eyes. you can use another CascadeClassifier to find them, or some landmarks, like from flandmark or dlib. then, it's basically this:
double eyeXdis = eye_r.x - eye_l.x;
double eyeYdis = eye_r.y - eye_l.y;
double angle = atan(eyeYdis/eyeXdis);
double degree = angle*180/CV_PI;
double desired_eye_distance = 44.0;
double scale = desired_eye_distance / eyeXdis;
Mat res;
Point2f center(test.cols/2, test.rows/2);
Mat rot = getRotationMatrix2D(center, degree, scale);
warpAffine(test, res, rot, Size(), INTER_CUBIC, BORDER_CONSTANT, Scalar(127));
// probably crop this again from center
4) now it's time to compare the images. ofc. you can save them to disk with imwrite() and use phash on that, but while you're in opencv, might as well try some other things:
double dist = norm(a,b);
and compare to some threshold