The original post is moved to my new personal blog
Very nice, thanks for sharing. However, I feel that it has some impact on performance and also on HTC Desire, switching from portrait back to landscape causes border to flicker. Unfortunately, I did not find out better solution so far except for ignoring orientation changes what is actually no problem in case of image processing but it may be not solution in case of complex GUI with standard android View components. Anyways, very helpful post.
It is a little trick I figure out when playing around with OpenCV on Android. May not be the optimal solution for orientation change issues, but worth a try.
Have you tried this on the most recent version of OpenCV? I can’t seem to get this to work.
I cant believe that the Authors of OpenCV wouldn’t include an easy way to deal with rotation?!
Either way, I’d love to hear if you’ve still got a way for this to work!
Actually, I ended up getting it to work, it is just slightly different now because they use a cached bitmap
Matrix matrix = new Matrix();
matrix.preTranslate((canvas.getWidth() – mCacheBitmap.getWidth()) / 2,(canvas.getHeight() – mCacheBitmap.getHeight()) / 2);
if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
matrix.postRotate(90f,(canvas.getWidth()) / 2,(canvas.getHeight()) / 2);
canvas.drawBitmap(mCacheBitmap, matrix, new Paint());
Tried the code and it worked fine here. Don’t quite understand the size problem. Is the size of the “mCacheBitmap” the same as the screen size? If so, should fill the screen in both orientations. Or you may look into the “mCacheBitmap” to find out. By the way, the bitmap can always be resized using “resized_bmp = Bitmap.createScaledBitmap(bmp, new_width, new_height, false)”
However, in my implementation, in portrait, the preview size is much smaller than in landscape (ie, it does not fill the screen). I assume that it is because it thinks that that is the largest size of screen that can fit in portrait. Is there any way to increase the preview size?
I’m facing the same issue, but I have no solution so far.
Fill in your details below or click an icon to log in:
You are commenting using your WordPress.com account. ( Log Out / Change )
You are commenting using your Twitter account. ( Log Out / Change )
You are commenting using your Facebook account. ( Log Out / Change )
You are commenting using your Google+ account. ( Log Out / Change )
Connecting to %s
Notify me of new comments via email.