android: camera_device: Fix value of orientation metadata

Android's orientation metadata cannot have identical numerical
value to libcamera's rotation property. This is due to the fact
that libcamera's rotation property specifies the correction angle
in anticlockwise direction whereas Android's orientation metadata
specifies the value in clockwise direction. Fix that by computing
corresponding value for clockwise direction from libcamera's rotation
property.

Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Umang Jain 2020-09-09 16:17:54 +05:30 committed by Laurent Pinchart
parent 9ac8f3e96f
commit e917655d06

View file

@ -265,12 +265,17 @@ int CameraDevice::initialize()
} }
/* /*
* The Android orientation metadata and libcamera rotation property are * The Android orientation metadata specifies its rotation correction
* defined differently but have identical numerical values for Android * value in clockwise direction whereas libcamera specifies the
* devices such as phones and tablets. * rotation property in anticlockwise direction. Read the libcamera's
* rotation property (anticlockwise) and compute the corresponding
* value for clockwise direction as required by the Android orientation
* metadata.
*/ */
if (properties.contains(properties::Rotation)) if (properties.contains(properties::Rotation)) {
orientation_ = properties.get(properties::Rotation); int rotation = properties.get(properties::Rotation);
orientation_ = (360 - rotation) % 360;
}
int ret = camera_->acquire(); int ret = camera_->acquire();
if (ret) { if (ret) {