feat(isp_af): added af scheme driver and stepping approx scheme driver

This commit is contained in:
Armando 2023-12-18 12:06:00 +08:00
parent bf1275d700
commit ff9b88d827
6 changed files with 123 additions and 1 deletions

View File

@ -117,6 +117,14 @@ examples/peripherals/jpeg/jpeg_decode:
- if: SOC_JPEG_CODEC_SUPPORTED != 1
depends_components:
- esp_driver_jpeg
examples/peripherals/isp/auto_focus:
disable:
- if: INCLUDE_DEFAULT == 1
temporary: true
reason: disable build temporarily # TODO: IDF-8895
depends_components:
- esp_driver_isp
examples/peripherals/lcd/i2c_oled:
disable:

View File

@ -0,0 +1,10 @@
set(srcs)
list(APPEND srcs "src/isp_af_scheme.c"
"src/isp_af_scheme_sa.c")
set(priv_requires "esp_driver_isp")
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS "include" "interface"
PRIV_REQUIRES ${priv_requires})

View File

@ -0,0 +1,37 @@
/*
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "sdkconfig.h"
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Type of ISP AF scheme handle
*/
typedef struct isp_af_scheme_t *isp_af_scheme_handle_t;
/**
* @brief ISP AF process, which is used to calculate definition threshold and luminance threshold for AF environment detector to detect environment change
*
* @param[in] scheme AF scheme handle
* @param[out] out_definition_thresh Calculated definition threshold
* @param[out] out_luminance_thresh Calculated luminance threshold
*
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG If the combination of arguments is invalid.
* - ESP_ERR_INVALID_STATE Driver state is invalid.
*/
esp_err_t isp_af_process(isp_af_scheme_handle_t scheme, int *out_definition_thresh, int *out_luminance_thresh);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,41 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdbool.h>
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct isp_af_scheme_t isp_af_scheme_t;
/**
* @brief ISP AF Scheme Interface
*/
struct isp_af_scheme_t {
/**
* @brief Do AF
*
* @param[in] arg ISP AF scheme specific context
* @param[out] definition_thresh Definition thresh that is updated according to the current definition, this can be used to set to the ISP AF Env detector
* @param[out] luminance_thresh Luminance thresh that is updated according to the current luminance, this can be used to set to the ISP AF Env detector
*
* @return
*/
esp_err_t (*af_process)(void *arg, int *out_definition_thresh, int *out_luminance_thresh);
/**
* @brief ISP AF scheme specific contexts
* Can be customized to difference AF schemes
*/
void *ctx;
};
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,26 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include <sys/cdefs.h>
#include "esp_types.h"
#include "sdkconfig.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_check.h"
#include "esp_heap_caps.h"
#include "isp_af_scheme.h"
#include "isp_af_scheme_interface.h"
const static char *TAG = "AF_SCHEME";
esp_err_t isp_af_process(isp_af_scheme_handle_t scheme, int *out_definition_thresh, int *out_luminance_thresh)
{
ESP_RETURN_ON_FALSE(scheme, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer");
ESP_RETURN_ON_FALSE(scheme->ctx, ESP_ERR_INVALID_STATE, TAG, "no scheme registered, create a scheme first");
return scheme->af_process(scheme->ctx, out_definition_thresh, out_luminance_thresh);
}

View File

@ -136,7 +136,7 @@ static esp_err_t s_af_process(void *arg, int *out_definition_thresh, int *out_lu
af_current_best = af_current;
}
ESP_LOGV(TAG, "af_sum: %d, af_current: %d.%d", af_sum, (int)af_current, (int)((int)(af_current * 1000) % 1000));
ESP_LOGV(TAG, "af_sum: %"PRId32", af_current: %"PRId32".%"PRId32, af_sum, (int)af_current, (int)((int)(af_current * 1000) % 1000));
}
// second search