[B2G][Helix][Camera][zhaodawei]Put the phone to Landscape orientation, capture a still image by the front camera, the image rotated 180 degree.

RESOLVED DUPLICATE of bug 898395

Status

Firefox OS
Gaia::Camera
P1
critical
RESOLVED DUPLICATE of bug 898395
5 years ago
5 years ago

People

(Reporter: lecky, Assigned: viralwang)

Tracking

unspecified
ARM
Gonk (Firefox OS)

Firefox Tracking Flags

(blocking-b2g:hd+)

Details

(Whiteboard: [POVB])

Attachments

(1 attachment)

287.98 KB, text/plain
Details
(Reporter)

Description

5 years ago
Created attachment 786694 [details]
Debugging log

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; aff-kingsoft-ciba; Zune 4.7)

Steps to reproduce:

1. Run the camera APP and switch to the front camera.
2. Put the phone to vertical orientation, take a picture or record a video. View them in the gallery.
3. Put the phone to Landscape orientation(rotated 90 degree or 270 degree), take a picture or record a video. View them in the gallery.


Actual results:

Step 2: The orientation of the image is correct.

Step 3: The images are rotated 180 degree.


Expected results:

In all orientations, the captured image should be correct.
(Reporter)

Updated

5 years ago
Severity: normal → blocker
OS: All → Gonk (Firefox OS)
Priority: -- → P1
Hardware: All → ARM

Updated

5 years ago
Flags: needinfo?(vliu)

Updated

5 years ago
Assignee: nobody → vliu
Flags: needinfo?(vliu)
Does this platform need a camera sensor orientation adjustment factor?

For example, see:
https://github.com/mozilla-b2g/android-device-unagi/blob/master/full_unagi.mk#L16
Actually, looks like a duplicate.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 894374

Comment 3

5 years ago
From message observation, the beta and gamma of orientation is not right causing this problem. Reopening it for bug tracking.
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: DUPLICATE → ---

Comment 4

5 years ago
Set it as dup according to the observation in Comment 3.
Status: REOPENED → RESOLVED
Last Resolved: 5 years ago5 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 898395
(Assignee)

Comment 5

5 years ago
This symptom comes from the orientation calulate in Camera.
It should be orientation issue as we're tracking now.
Assignee: vliu → vwang
(Reporter)

Comment 6

5 years ago
(In reply to viral [:viralwang] from comment #5)
> This symptom comes from the orientation calulate in Camera.
It should be
> orientation issue as we're tracking now.

Please see the file './frameworks/base/core/jave/android/hardware/Camera.jave'.
You can find some information as following:
        /**
         * Sets the rotation angle in degrees relative to the orientation of
         * the camera. This affects the pictures returned from JPEG {@link
         * PictureCallback}. The camera driver may set orientation in the
         * EXIF header without rotating the picture. Or the driver may rotate
         * the picture and the EXIF thumbnail. If the Jpeg picture is rotated,
         * the orientation in the EXIF header will be missing or 1 (row #0 is
         * top and column #0 is left side).
         *
         * <p>If applications want to rotate the picture to match the orientation
         * of what users see, apps should use {@link
         * android.view.OrientationEventListener} and {@link CameraInfo}.
         * The value from OrientationEventListener is relative to the natural
         * orientation of the device. CameraInfo.orientation is the angle
         * between camera orientation and natural device orientation. The sum
         * of the two is the rotation angle for back-facing camera. The
         * difference of the two is the rotation angle for front-facing camera.
         * Note that the JPEG pictures of front-facing cameras are not mirrored
         * as in preview display.
         *
         * <p>For example, suppose the natural orientation of the device is
         * portrait. The device is rotated 270 degrees clockwise, so the device
         * orientation is 270. Suppose a back-facing camera sensor is mounted in
         * landscape and the top side of the camera sensor is aligned with the
         * right edge of the display in natural orientation. So the camera
         * orientation is 90. The rotation should be set to 0 (270 + 90).
         *
         * <p>The reference code is as follows.
         *
         * <pre>
         * public void onOrientationChanged(int orientation) {
         *     if (orientation == ORIENTATION_UNKNOWN) return;
         *     android.hardware.Camera.CameraInfo info =
         *            new android.hardware.Camera.CameraInfo();
         *     android.hardware.Camera.getCameraInfo(cameraId, info);
         *     orientation = (orientation + 45) / 90 * 90;
         *     int rotation = 0;
         *     if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
         *         rotation = (info.orientation - orientation + 360) % 360;
         *     } else {  // back-facing camera
         *         rotation = (info.orientation + orientation) % 360;
         *     }
         *     mParameters.setRotation(rotation);
         * }
         * </pre>
         *
         * @param rotation The rotation angle in degrees relative to the
         *                 orientation of the camera. Rotation can only be 0,
         *                 90, 180 or 270.
         * @throws IllegalArgumentException if rotation value is invalid.
         * @see android.view.OrientationEventListener
         * @see #getCameraInfo(int, CameraInfo)
         */

As mentioned above in the sample codes, we do the same changes in our codes as follows.
'./gecko/dom/camera/GonkCameraControl.cpp'
nsresult
nsGonkCameraControl::TakePictureImpl(TakePictureTask* aTakePicture)
{
  ...
  // Convert 'rotation' to a positive value from 0..270 degrees, in steps of 90.
  uint32_t r = static_cast<uint32_t>(aTakePicture->mRotation);

  if( mCameraId == CAMERA_FACING_FRONT )  //add line
  {  //add line
    r = (mCameraHw->GetSensorOrientation() - static_cast<uint32_t>(aTakePicture->mRotation) + 360);  //add line 
  }  //add line
  else  //add line
  {  //add line
    r += mCameraHw->GetSensorOrientation();
  }  //add line

  r %= 360;
  r += 45;
  r /= 90;
  r *= 90;
  ...
}

It can fix this issue.
Maybe we also can do this changes in the APP side? 

PS: Acordding to the above changes, we also need to add the same changes on function SetupRecording().
(In reply to lecky from comment #6)
> 
> PS: According to the above changes, we also need to add the same changes on
> function SetupRecording().

We spent a lot of time getting the orientation part of gecko APIs correct for picture-taking and video-recording on platforms other than Helix. If you think there's something wrong with them, please describe the problem explicitly.

From what I've seen, the problem is with how the orientation values from the platform are being interpreted in the Camera application.
(Reporter)

Comment 8

5 years ago
(In reply to Mike Habicher [:mikeh] from comment #7)
> (In reply to lecky from comment #6)
> 
> PS: According to the above changes,
> we also need to add the same changes on
> function SetupRecording().

We
> spent a lot of time getting the orientation part of gecko APIs correct for
> picture-taking and video-recording on platforms other than Helix. If you
> think there's something wrong with them, please describe the problem
> explicitly.

From what I've seen, the problem is with how the orientation
> values from the platform are being interpreted in the Camera application.

Did you find some differents about the orientatin values between the platform and the camera application from the debug log?

I think that the processing method must be different between back camera and front camera. 
For example, suppose that the mount angle of back camera and front camera are both 0 degree. When we hand the phone Vertically and take picture,the angles of both image are all 0 degree. You do not need to rotate the image.
If you rotate the phone 90 degree clockwise, the mount angle of back camera is 90 degree, but the mount angle of front camera is 270 degree. So we neet to rotate the back camera imgae 270 degree clockwise and the front camera 90 degree clockwise.
(Reporter)

Updated

5 years ago
blocking-b2g: --- → hd?
(Reporter)

Updated

5 years ago
Severity: blocker → critical
HD+ as this is device specific and needs to be resolved.
blocking-b2g: hd? → hd+
blocking-b2g: hd+ → hd?
Whiteboard: [POVB]
correcting blocking flag
blocking-b2g: hd? → hd+
You need to log in before you can comment on or make changes to this bug.