Face preprocessing is not working in java. [closed]
I am working on face recognition using java library of open cv. I got stuck on face pre processsing phase. here is my code.
double desiredFaceHeight=70;
double desiredFaceWidth=70;
double desiredLen=(DESIRED_RIGHT_EYE_X-0.16);
try{
double dy= (face.getRightEye().y-face.getLeftEye().y);
double dx= (face.getRightEye().x-face.getLeftEye().x);
double len=Math.sqrt((dx*dx)+(dy*dy));
double scale=desiredLen*desiredFaceWidth/len;
// Get the transformation matrix for the desired angle & size.
Mat rotMat=Imgproc.getRotationMatrix2D(face.getCenterOfEyes(),face.getEyesAngle(), scale);
//Shift the center of the eyes to be the desired center.
double ex= desiredFaceWidth*0.5f-face.getCenterOfEyes().x;
double ey=desiredFaceHeight*DESIRED_LEFT_EYE_Y-face.getCenterOfEyes().y;
rotMat.put(0,2,rotMat.get(0,2)[0]+ex);//view
rotMat.put(1,2,rotMat.get(1,2)[0]+ey);//view
Mat warped = new Mat((int)desiredFaceHeight, (int)desiredFaceWidth,CvType.CV_8U,new Scalar(128));
//Mat warped=face.getFace();
Imgproc.warpAffine(face.getFace(),warped, rotMat, warped.size());
but it does not gives transformed face. please describe what's wrong I am doing.
similar prob here - let me guess, scale & offset is right, but (almost) no rotation ?
I have checked rotation matrix. values are getting change.
Just a guess, this complete code depends on the fact that there is actually a detection of both eyes. Where do you catch the fact that one of these parameters is unknown?
@StevenPuttemans I am actually accepting only those faces in which both eyes are detected.
Okay was a simple guess, no idea why it doesn't do what its supposed to do... not a java expert here...
I got what the problem was. actually the center of face about which the face was rotated was calculated wrongly.
Ok than this can be closed and marked as solved.