[libcamera-devel] [PATCH 2/5] android: camera_device: Construct manual request template
Niklas Söderlund
niklas.soderlund at ragnatech.se
Wed Jul 29 01:56:06 CEST 2020
Hi Jacopo,
Thanks for your work.
On 2020-07-25 18:42:40 +0200, Jacopo Mondi wrote:
> Construct the template for the MANUAL capture intent.
>
> The constructed control pack is quite similar to the one used for
> preview, with the exception that the 3A functionalities are disabled.
>
> This fixes the CTS 9.0.r12 test:
> android.hardware.camera2.cts.CameraDeviceTest#testCameraDeviceManualTemplate
>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
> src/android/camera_device.cpp | 91 ++++++++++++++++++++++++++++++++++-
> src/android/camera_device.h | 1 +
> 2 files changed, 91 insertions(+), 1 deletion(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index fa4570fabdd7..de18d1dbe299 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -917,6 +917,90 @@ CameraMetadata *CameraDevice::requestTemplatePreview()
> return requestTemplate;
> }
>
> +CameraMetadata *CameraDevice::requestTemplateManual()
> +{
> + /*
> + * \todo Keep this in sync with the actual number of entries.
> + * Currently: 20 entries, 35 bytes
> + */
I think this is starting to become a pain point for us and we need to
make this automatic somehow. It does not have to be done as part of this
series and I think Kieran is already working on it so for this patch,
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> + CameraMetadata *requestTemplate = new CameraMetadata(20, 35);
> + if (!requestTemplate->isValid()) {
> + delete requestTemplate;
> + return nullptr;
> + }
> +
> + uint8_t aeMode = ANDROID_CONTROL_AE_MODE_OFF;
> + requestTemplate->addEntry(ANDROID_CONTROL_AE_MODE,
> + &aeMode, 1);
> +
> + int32_t aeExposureCompensation = 0;
> + requestTemplate->addEntry(ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION,
> + &aeExposureCompensation, 1);
> +
> + uint8_t aePrecaptureTrigger = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE;
> + requestTemplate->addEntry(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER,
> + &aePrecaptureTrigger, 1);
> +
> + uint8_t aeLock = ANDROID_CONTROL_AE_LOCK_OFF;
> + requestTemplate->addEntry(ANDROID_CONTROL_AE_LOCK,
> + &aeLock, 1);
> +
> + std::vector<int32_t> aeFpsTarget = {
> + 15, 30,
> + };
> + requestTemplate->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
> + aeFpsTarget.data(),
> + aeFpsTarget.size());
> +
> + uint8_t aeAntibandingMode = ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO;
> + requestTemplate->addEntry(ANDROID_CONTROL_AE_ANTIBANDING_MODE,
> + &aeAntibandingMode, 1);
> +
> + uint8_t afTrigger = ANDROID_CONTROL_AF_TRIGGER_IDLE;
> + requestTemplate->addEntry(ANDROID_CONTROL_AF_TRIGGER,
> + &afTrigger, 1);
> +
> + uint8_t awbMode = ANDROID_CONTROL_AWB_MODE_OFF;
> + requestTemplate->addEntry(ANDROID_CONTROL_AWB_MODE,
> + &awbMode, 1);
> +
> + uint8_t awbLock = ANDROID_CONTROL_AWB_LOCK_OFF;
> + requestTemplate->addEntry(ANDROID_CONTROL_AWB_LOCK,
> + &awbLock, 1);
> +
> + uint8_t flashMode = ANDROID_FLASH_MODE_OFF;
> + requestTemplate->addEntry(ANDROID_FLASH_MODE,
> + &flashMode, 1);
> +
> + uint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;
> + requestTemplate->addEntry(ANDROID_STATISTICS_FACE_DETECT_MODE,
> + &faceDetectMode, 1);
> +
> + uint8_t noiseReduction = ANDROID_NOISE_REDUCTION_MODE_OFF;
> + requestTemplate->addEntry(ANDROID_NOISE_REDUCTION_MODE,
> + &noiseReduction, 1);
> +
> + uint8_t aberrationMode = ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF;
> + requestTemplate->addEntry(ANDROID_COLOR_CORRECTION_ABERRATION_MODE,
> + &aberrationMode, 1);
> +
> + uint8_t controlMode = ANDROID_CONTROL_MODE_OFF;
> + requestTemplate->addEntry(ANDROID_CONTROL_MODE, &controlMode, 1);
> +
> + float lensAperture = 2.53 / 100;
> + requestTemplate->addEntry(ANDROID_LENS_APERTURE, &lensAperture, 1);
> +
> + uint8_t opticalStabilization = ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF;
> + requestTemplate->addEntry(ANDROID_LENS_OPTICAL_STABILIZATION_MODE,
> + &opticalStabilization, 1);
> +
> + uint8_t captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW;
> + requestTemplate->addEntry(ANDROID_CONTROL_CAPTURE_INTENT,
> + &captureIntent, 1);
> +
> + return requestTemplate;
> +}
> +
> /*
> * Produce a metadata pack to be used as template for a capture request.
> */
> @@ -931,21 +1015,27 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)
> uint8_t captureIntent;
> switch (type) {
> case CAMERA3_TEMPLATE_PREVIEW:
> + requestTemplate = requestTemplatePreview();
> captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW;
> break;
> case CAMERA3_TEMPLATE_STILL_CAPTURE:
> + requestTemplate = requestTemplatePreview();
> captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE;
> break;
> case CAMERA3_TEMPLATE_VIDEO_RECORD:
> + requestTemplate = requestTemplatePreview();
> captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD;
> break;
> case CAMERA3_TEMPLATE_VIDEO_SNAPSHOT:
> + requestTemplate = requestTemplatePreview();
> captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT;
> break;
> case CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG:
> + requestTemplate = requestTemplatePreview();
> captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG;
> break;
> case CAMERA3_TEMPLATE_MANUAL:
> + requestTemplate = requestTemplateManual();
> captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_MANUAL;
> break;
> default:
> @@ -953,7 +1043,6 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)
> return nullptr;
> }
>
> - requestTemplate = requestTemplatePreview();
> if (!requestTemplate || !requestTemplate->isValid()) {
> LOG(HAL, Error) << "Failed to construct request template";
> delete requestTemplate;
> diff --git a/src/android/camera_device.h b/src/android/camera_device.h
> index 5a52ad8f741c..db7b3c558993 100644
> --- a/src/android/camera_device.h
> +++ b/src/android/camera_device.h
> @@ -84,6 +84,7 @@ private:
> void notifyShutter(uint32_t frameNumber, uint64_t timestamp);
> void notifyError(uint32_t frameNumber, camera3_stream_t *stream);
> CameraMetadata *requestTemplatePreview();
> + CameraMetadata *requestTemplateManual();
> libcamera::PixelFormat toPixelFormat(int format);
> std::unique_ptr<CameraMetadata> getResultMetadata(int frame_number,
> int64_t timestamp);
> --
> 2.27.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list