Hi,
I am creating an application for face recognition using opencv in android.App is working good in landscape mode. I want to use this app in portrait mode for this I added following code in onCameraFrame method :-
int height = mGray.rows();
int faceSize = Math.round(height * 0.4f);
Mat temp = mGray.clone();
Core.transpose(mGray, temp);
Core.flip(temp, temp, -1);
MatOfRect faces = new MatOfRect();
mJavaDetector.detectMultiScale(mRgba, mJavaDetector.detectMultiScale(temp, faces, 1.1, 2, 2, new Size(faceSize, faceSize), new Size());
I also did changes in CameraBridgeViewBase. I following code
canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()),
new Rect((int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2),
(int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2),
(int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2 + mScale*mCacheBitmap.getWidth()),
(int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2 + mScale*mCacheBitmap.getHeight())), null);
with
Matrix matrix = new Matrix();
matrix.preTranslate( (int)(canvas.getWidth() - mCacheBitmap.getWidth()) / 2,(canvas.getHeight() - mCacheBitmap.getHeight()) / 2);
if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
matrix.postRotate(270f,( (int)canvas.getWidth()) / 2,(canvas.getHeight()) / 2);
canvas.drawBitmap(mCacheBitmap, matrix, new Paint());
But its not working in portrait mode.When I am rotating device from portrait to landscape , then camera shows in portrait mode. working.Face detector mark is not coming exactly surrounding user's face. It is coming slightly down and right side of the face. I have attached screenshot of this.
Screenshot_2014-03-18-15-13-50.png
Please help me to resolve this issue..
problem.
Thanks in advance !!