Skip to content

Portrait orientation on Android #4704

@opencv-pushbot

Description

@opencv-pushbot

Transferred from http://code.opencv.org/issues/3565

|| Sergey Abdula on 2014-02-20 04:06
|| Priority: Normal
|| Affected: 2.4.0 - 2.4.7
|| Category: android
|| Tracker: Bug
|| Difficulty: Easy
|| PR: 
|| Platform: ARM / Android

Portrait orientation on Android

Hi,
If to change  android:screenOrientation from landscape to portrait mode in "OpenCVTutorial 1 - Camera Preview", an image is rotated to 270 degree clockwise.

It's pretty basic feature for mobile applications (easy change orientation) and if I understand correctly, it was discussed last year (see http://stackoverflow.com/questions/14816166/rotate-camera-preview-to-portrait-android-opencv-camera). However, I could not find any opened or closed issue related to this problem.

There is kind of way to fix it (see http://littlecheesecake.me/blog/13804736/opencv-android-orientation) but it's required to rewrite the basic class (which is not good idea) and it does not work properly anyway.

Thanks in advance.

Sergey

History

Alexander Karsakov on 2014-02-20 06:53
-   Status changed from New to Open
Alexander Smorkalov on 2014-02-25 07:24
-   Target version set to 2.4.9
-   Difficulty set to Easy
Sergey Abdula on 2014-03-14 02:43
Hi Alex,

It will be nice to have a taken picture in correct orientation in portrait mode as well.
Alexander Smorkalov on 2014-04-01 23:12
We cannot change API behavior in 2.4 branch. I reasign the task on 3.0 release (master branch). It will not be compatible with 2.4.x, so we can change API behavour and fix such issues.
-   Target version changed from 2.4.9 to 3.0
Stephen G on 2015-05-06 02:09
Found the error in calculateCameraFrameSize in CameraBridgeViewBase.

A. mMaxWidth/Height are never set and should be (easily done by overriding onSizeChanged in the CameraView and calling setMaxFrameSize)

B. the supportedSizes list only list the max hieght/widths in one dimensions. the comparisons done in the weird double if statements need to be completed for width <= maxAllowedWidth ... *&& height <= maxAllowedWidth ...*. Then, the mScale calculate also needs to take this change into account with something like this: 
<pre>
mScale = Math.max(
    Math.min(((float) height) / mFrameHeight, ((float) width) / mFrameWidth),
    Math.min(((float) width) / mFrameHeight, ((float) height) / mFrameWidth)
);
</pre>

This solution doesn't fill the whole screen, but it does keep the proper ratio.

Does it work? could it be updated for 3 since it's still in an RC state?
Andrea Tomassetti on 2015-05-19 11:37
Alexander Smorkalov wrote:
> We cannot change API behavior in 2.4 branch. I reasign the task on 3.0 release (master branch). It will not be compatible with 2.4.x, so we can change API behavour and fix such issues.

Hi, I've just downloaded OpenCV 3.0RC1 for Android but there is the same issue. I'm wrong? It was fixed?

Thanks in advance
Fabian Hoyos on 2015-07-03 16:25
Hi, would I like to know if the bug Portrait orientation on Android is fixed in the version 3.0 of opencv Android SDK. I have the same problem when I use opencv Android sdk in mode portrait in the app to open the camera and face detection. 

Thanks for information. I hope soon know the solution, please.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions