How to use JavaCameraView in portrait mode?
Hello.
How do I use the JavaCameraView from OpenCV in portrait mode?
I found lots of solutions but they end of not working when I need to use the
FeatureDetector detector = FeatureDetector.create(FeatureDetector.MSER);
for example. Like others have noted, It presumes that the picture is in landscape mode when I pass it the
detector.detect(mGrey, keypoints);
I tried all kind of trickery like doing:
May copy = new Mat();
Code.flip(mGrey.t(), copy, 1);
detector.detect(mGrey, keypoints);
It doesn't seem to work though.
I think I need to do - with the nGrey matrix - the inverse of (from the example above) :
private Matrix rotateMe(Canvas canvas, Bitmap bm) {
// TODO Auto-generated method stub
Matrix mtx=new Matrix();
float scale = (float) canvas.getWidth() / (float) bm.getHeight();
mtx.preTranslate((canvas.getWidth() - bm.getWidth())/2, (canvas.getHeight() - bm.getHeight())/2);
mtx.postRotate(90,canvas.getWidth()/2, canvas.getHeight()/2);
mtx.postScale(scale, scale, canvas.getWidth()/2 , canvas.getHeight()/2 );
return mtx;
}
If anyone know how to overcome this problem - by hook or by crook - let me know.
To re-iterate, how do I correctly show the JavaCameraView
in landscape mode? Correctly should mean that the FeatureDetector
should be able to process the image, mGrey
matrix, correctly. Right now, the FeatureDetector
views the image in landscape mode even if I hold the phone in portrait mode. So when it selects text areas in the image, it selects them vertically and incorrectly. When I flip the phone in landscape mode, it select everything correctly. I much prefer portrait mode for my app.
Thank you kindly in advance.