android: camera_device: Use Camera properties for static Metadata
Construct two example static metadata to be reported to the Android framework using the properties reported by the Camera. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
f8951ee720
commit
857a216fd5
1 changed files with 27 additions and 2 deletions
|
@ -8,6 +8,9 @@
|
||||||
#include "camera_device.h"
|
#include "camera_device.h"
|
||||||
#include "camera_ops.h"
|
#include "camera_ops.h"
|
||||||
|
|
||||||
|
#include <libcamera/controls.h>
|
||||||
|
#include <libcamera/property_ids.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
@ -109,6 +112,8 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
|
||||||
if (staticMetadata_)
|
if (staticMetadata_)
|
||||||
return staticMetadata_->get();
|
return staticMetadata_->get();
|
||||||
|
|
||||||
|
const ControlList &properties = camera_->properties();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The here reported metadata are enough to implement a basic capture
|
* The here reported metadata are enough to implement a basic capture
|
||||||
* example application, but a real camera implementation will require
|
* example application, but a real camera implementation will require
|
||||||
|
@ -273,9 +278,15 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
|
||||||
staticMetadata_->addEntry(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE,
|
staticMetadata_->addEntry(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE,
|
||||||
&exposureTimeRange, 2);
|
&exposureTimeRange, 2);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The Android orientation metadata and libcamera rotation property are
|
||||||
|
* defined differently but have identical numerical values for Android
|
||||||
|
* devices such as phones and tablets.
|
||||||
|
*/
|
||||||
int32_t orientation = 0;
|
int32_t orientation = 0;
|
||||||
staticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION,
|
if (properties.contains(properties::Rotation))
|
||||||
&orientation, 1);
|
orientation = properties.get(properties::Rotation);
|
||||||
|
staticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION, &orientation, 1);
|
||||||
|
|
||||||
std::vector<int32_t> testPatterModes = {
|
std::vector<int32_t> testPatterModes = {
|
||||||
ANDROID_SENSOR_TEST_PATTERN_MODE_OFF,
|
ANDROID_SENSOR_TEST_PATTERN_MODE_OFF,
|
||||||
|
@ -322,6 +333,20 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
|
||||||
lensApertures.size());
|
lensApertures.size());
|
||||||
|
|
||||||
uint8_t lensFacing = ANDROID_LENS_FACING_FRONT;
|
uint8_t lensFacing = ANDROID_LENS_FACING_FRONT;
|
||||||
|
if (properties.contains(properties::Location)) {
|
||||||
|
int32_t location = properties.get(properties::Location);
|
||||||
|
switch (location) {
|
||||||
|
case properties::CameraLocationFront:
|
||||||
|
lensFacing = ANDROID_LENS_FACING_FRONT;
|
||||||
|
break;
|
||||||
|
case properties::CameraLocationBack:
|
||||||
|
lensFacing = ANDROID_LENS_FACING_BACK;
|
||||||
|
break;
|
||||||
|
case properties::CameraLocationExternal:
|
||||||
|
lensFacing = ANDROID_LENS_FACING_EXTERNAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
staticMetadata_->addEntry(ANDROID_LENS_FACING, &lensFacing, 1);
|
staticMetadata_->addEntry(ANDROID_LENS_FACING, &lensFacing, 1);
|
||||||
|
|
||||||
std::vector<float> lensFocalLenghts = {
|
std::vector<float> lensFocalLenghts = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue