Closed Bug 1015846 Opened 10 years ago Closed 10 years ago

[Vixen][Tablet] Camera preview rotate 90 degrees in camera app

Categories

(Firefox OS Graveyard :: Gaia::Camera, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: atsai, Unassigned)

References

Details

(Whiteboard: [Vixen])

Attachments

(2 files)

** The case is by the testing on Vixen Tablet devices. It might not be able to reproduce on other mobile devices **

Camera will rotate 90 degrees in preview mode

Gaia      7f258dbcbaab4d1b0a5416b974b97285582283d5
Gecko     d6d67da827d0180b95db2592b725321f6102d141
BuildID   20140520190311
Version   32.0a1
ro.build.version.incremental=eng.waynechen.20140520.184405
ro.build.date=二  5月 20 18:44:35 CST 2014
Blocks: vixen
It seems the orientation defined in Camera HAL causes this problem. I modified the code below, and vixen got the correct angle for preview and taking picture. We need partner's support to figure it out. Thanks.

diff --git a/libcamera/CameraFactory.cpp b/libcamera/CameraFactory.cpp
index 50f95a5..9122e9a 100644
--- a/libcamera/CameraFactory.cpp
+++ b/libcamera/CameraFactory.cpp
@@ -260,7 +260,7 @@ static int camera_device_close(hw_device_t* device)
 static android::CameraInfo sCameraInfo[] = {
     {
         CAMERA_FACING_BACK,
-        90,                     /* orientation */
+        0,                     /* orientation */
     },
     {
         CAMERA_FACING_FRONT,
Flags: needinfo?(wchang)
Flags: needinfo?(awu)
I confirmed that the patch works for me for the issue.

In ffos, gaia calls into nsDOMCameraControl::SensorAngle() to get angle reported from Camera HAL to operate transform. 

http://lxr.mozilla.org/mozilla-central/source/dom/camera/DOMCameraControl.cpp#609

As I know device like handset (tall screen device) has 90 degree orientation compared with camera sensor because user looks it in portrait mode by default. For tablet device, 0 degree is expected when users operate it in landscape mode by default.

Please also see the definition for orientation in av/include/camera/Camera.h 

    /**
     * The orientation of the camera image. The value is the angle that the
     * camera image needs to be rotated clockwise so it shows correctly on the
     * display in its natural orientation. It should be 0, 90, 180, or 270.
     *
     * For example, suppose a device has a naturally tall screen. The
     * back-facing camera sensor is mounted in landscape. You are looking at
     * the screen. If the top side of the camera sensor is aligned with the
     * right edge of the screen in natural orientation, the value should be
     * 90. If the top side of a front-facing camera sensor is aligned with the
     * right of the screen, the value should be 270.
     */
hi vincent
Attached video 20140612093.mp4
 hi vincent
    I am toby from via. responsible for camera issues .After I got the newest source code .And I modified the code as below in camera HAL. I got the correct angle for preview and taking picture. but I think there are still two problems:
1,The preview image can not fill full screen after I modified as below 2,When I take a picture and view the picture from control button and return preview,then the preview image rotate 90 degree. I have recoreded by phone about the whole operation.Please look at the attachment in comment 4 about this Phenomenon.


static android::CameraInfo sCameraInfo[] = {
    {
        CAMERA_FACING_BACK,
        0,                     /* orientation */
    },
    {
        CAMERA_FACING_FRONT,
        180,                    /* orientation */
    },
};
(In reply to tobydeng from comment #5)

> 2,When I take a picture and view the picture from control button and return
> preview,then the preview image rotate 90 degree. I have recoreded by phone
> about the whole operation.Please look at the attachment in comment 4 about
> this Phenomenon.
> 
> 
> static android::CameraInfo sCameraInfo[] = {
>     {
>         CAMERA_FACING_BACK,
>         0,                     /* orientation */
>     },
>     {
>         CAMERA_FACING_FRONT,
>         180,                    /* orientation */
>     },
> };

For 2, is it a gaia issue? Can you have look for this? Thanks.
Flags: needinfo?(johu)
hi vincent
hi vincent 
   I think it is a gaia issue.But I am mainly responsible for driver and HAL about camera,I have not ability to look for the application problem. Can you give me some support? Thanks

(In reply to Vincent Liu[:vliu] from comment #6)
> (In reply to tobydeng from comment #5)
> 
> > 2,When I take a picture and view the picture from control button and return
> > preview,then the preview image rotate 90 degree. I have recoreded by phone
> > about the whole operation.Please look at the attachment in comment 4 about
> > this Phenomenon.
> 
> For 2, is it a gaia issue? Can you have look for this? Thanks.

If you are talking about the rotation issue, yes, it is gaia issue. It is caused by the line[1]. We should lock the orientation at "default" instead of "portrait-primary", like the one in manifest[2].

I had CCed camera guys in this bug.

[1] https://github.com/mozilla-b2g/gaia/blob/c0709e95fa79e35913e3e6788e80cd874d29990e/apps/camera/js/lib/orientation.js#L33
[2] https://github.com/mozilla-b2g/gaia/blob/c0709e95fa79e35913e3e6788e80cd874d29990e/apps/camera/manifest.webapp#L6
Flags: needinfo?(johu)
BTW, I found another issue at the video of comment4. User needs to tap the screen to see the preview. I never found that at any device. If this issue is confirmed, please file another one to track it.
The patch found be found here. I will set review while try and travis is green.
Comment on attachment 8440561 [details] [review]
replace portrait-primary with default

Hi Diego,

This patch updates the locked orientation from the "portrait-primary" to "default" to be consistent with the manifest.webapp. Please review this patch. Thanks.

The travis is green: https://travis-ci.org/mozilla-b2g/gaia/builds/27660447
The try-server is green but with a known intermittent error: https://tbpl.mozilla.org/?tree=Gaia-Try&rev=643e0bde6192cd547ebc09fa1c05636a7e4c5e2a
Attachment #8440561 - Flags: review?(dmarcos)
Hi all,

After patch comment 5 & comment 12, Camera preview & shot works fine.

Sincerely,
Wayne
However,

After switch to camcorder, I think driver has some problem. Following is log:

06-17 05:35:43.495 W/V4L2Camera(   81): V4L2 not open when call startPreview
06-17 05:35:43.496 I/V4L2Camera(   81): Name of input channel[0] is Camera 0

Sincerely,
Wayne
The camera orientation is designed for portrait orientation. I don't have any tablet to test it. If we lock the orientation to default how does the camera behaves? Is it rendered in landscape orientation? Do you have any screenshot?
Flags: needinfo?(johu)
Yes, it is rendered at landscape mode and works correctly. I can make a video for you.
Flags: needinfo?(johu)
How is the default orientation decided? How can I make sure that in all the phones default corresponds to 'portrait-primary'?
Flags: needinfo?(johu)
Diego,

https://www.youtube.com/watch?v=CvUi_RYhIZo&feature=youtu.be is the camera app running in Flatfish. It works correctly. I think the point of this issue is the inconsistent between manifest and lib/orientation.js. If "portrait-primary" is correct, we should update both to portrait-primary. If the "default" is correct, we should update them to default.
Flags: needinfo?(johu) → needinfo?(dmarcos)
Default orientation is decided by build time. It will be one of the "portrait-primary" or "landscape-primary". And it is handled by gecko.
Did you make any changes in camera specific to tablet? The app looks better than expected. I had never seen before running on a tablet
Flags: needinfo?(dmarcos) → needinfo?(johu)
Attachment #8440561 - Flags: review?(dmarcos) → review+
Flags: needinfo?(wchang)
(In reply to Diego Marcos [:dmarcos] from comment #20)
> Did you make any changes in camera specific to tablet? The app looks better
> than expected. I had never seen before running on a tablet

No, I don't change anything. That works as normal from v1.3 to master.
Flags: needinfo?(johu)
merged to master:
https://github.com/mozilla-b2g/gaia/commit/3b52807f4bc6e84166433c6b23837dcc5f7b8554
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
tested on local build. it works well.
Status: RESOLVED → VERIFIED
Flags: needinfo?(awu)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: