stm-st-stm32mp: evision: add evision libraries
These libraries are required by libcamera when IPA support is enabled. Import them from the meta-OpenSTLinux layer at the openstlinux-6.6-yocto-scarthgap-mpu-v26.02.18 tag. https://onedigi.atlassian.net/browse/DEL-10021 Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
This commit is contained in:
parent
17d1f19a48
commit
a5eb54435e
|
|
@ -0,0 +1,61 @@
|
|||
# Copyright (C) 2024, STMicroelectronics - All Rights Reserved
|
||||
SUMMARY = "evision package to install AE an AWB algorithm libraries"
|
||||
LICENSE = "SLA0044"
|
||||
LIC_FILES_CHKSUM = "file://evision-libs/LICENSE;md5=91fc08c2e8dfcd4229b69819ef52827c"
|
||||
|
||||
NO_GENERIC_LICENSE[SLA0044] = "evision-libs/LICENSE"
|
||||
LICENSE:${PN} = "SLA0044"
|
||||
|
||||
SRC_URI = "file://evision-libs/;subdir=${BPN}-${PV} \
|
||||
"
|
||||
|
||||
COMPATIBLE_MACHINE = "^(aarch64)"
|
||||
|
||||
# Configure evision output library dir
|
||||
ST_SPECIFIC_OUTPUT_LIBDIR ??= "${libdir}"
|
||||
|
||||
EVISION_LDCONF ?= "evision.conf"
|
||||
|
||||
S = "${WORKDIR}/${BPN}-${PV}"
|
||||
|
||||
do_configure[noexec] = "1"
|
||||
|
||||
do_compile() {
|
||||
# Generate specific conf file if required
|
||||
if [ "${ST_SPECIFIC_OUTPUT_LIBDIR}" = "${libdir}" ]; then
|
||||
bbnote "evision output libdir is default one (${libdir})"
|
||||
echo "" > ${B}/${EVISION_LDCONF}
|
||||
else
|
||||
bbnote "evision output libdir set to ${ST_SPECIFIC_OUTPUT_LIBDIR}: generate specific conf file for ldconfig"
|
||||
echo ${ST_SPECIFIC_OUTPUT_LIBDIR} > ${B}/${EVISION_LDCONF}
|
||||
fi
|
||||
}
|
||||
|
||||
do_install() {
|
||||
# includes
|
||||
install -m 0755 -d ${D}${includedir}/evision
|
||||
install -m 0644 ${S}/evision-libs/*.h ${D}${includedir}/evision
|
||||
install -m 0644 ${S}/evision-libs/LICENSE ${D}${includedir}/evision
|
||||
|
||||
# libraries
|
||||
install -m 0755 -d ${D}${ST_SPECIFIC_OUTPUT_LIBDIR}
|
||||
install -m 0755 ${S}/evision-libs/*.so.* ${D}${ST_SPECIFIC_OUTPUT_LIBDIR}/
|
||||
|
||||
# ldconfig file
|
||||
if [ -s "${B}/${EVISION_LDCONF}" ]; then
|
||||
install -d ${D}${sysconfdir}/ld.so.conf.d/
|
||||
install -m 0644 "${B}/${EVISION_LDCONF}" ${D}${sysconfdir}/ld.so.conf.d/
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
PACKAGES += "\
|
||||
evision-ldconf \
|
||||
"
|
||||
FILES:${PN} = "${ST_SPECIFIC_OUTPUT_LIBDIR}/*.so.*"
|
||||
FILES:evision-ldconf = "${sysconfdir}/ld.so.conf.d/*"
|
||||
ALLOW_EMPTY:${evision-ldconf} = "1"
|
||||
|
||||
RDEPENDS:${PN} += "\
|
||||
evision-ldconf \
|
||||
"
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
SLA0044 Rev5/February 2018
|
||||
|
||||
Software license agreement
|
||||
|
||||
ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT
|
||||
|
||||
BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE
|
||||
OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS
|
||||
INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES
|
||||
(STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON
|
||||
BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES
|
||||
TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT.
|
||||
|
||||
Under STMicroelectronics’ intellectual property rights, the redistribution,
|
||||
reproduction and use in source and binary forms of the software or any part
|
||||
thereof, with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
1. Redistribution of source code (modified or not) must retain any copyright
|
||||
notice, this list of conditions and the disclaimer set forth below as items 10
|
||||
and 11.
|
||||
|
||||
2. Redistributions in binary form, except as embedded into microcontroller or
|
||||
microprocessor device manufactured by or for STMicroelectronics or a software
|
||||
update for such device, must reproduce any copyright notice provided with the
|
||||
binary code, this list of conditions, and the disclaimer set forth below as
|
||||
items 10 and 11, in documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
3. Neither the name of STMicroelectronics nor the names of other contributors to
|
||||
this software may be used to endorse or promote products derived from this
|
||||
software or part thereof without specific written permission.
|
||||
|
||||
4. This software or any part thereof, including modifications and/or derivative
|
||||
works of this software, must be used and execute solely and exclusively on or in
|
||||
combination with a microcontroller or microprocessor device manufactured by or
|
||||
for STMicroelectronics.
|
||||
|
||||
5. No use, reproduction or redistribution of this software partially or totally
|
||||
may be done in any manner that would subject this software to any Open Source
|
||||
Terms. “Open Source Terms” shall mean any open source license which requires as
|
||||
part of distribution of software that the source code of such software is
|
||||
distributed therewith or otherwise made available, or open source license that
|
||||
substantially complies with the Open Source definition specified at
|
||||
www.opensource.org and any other comparable open source license such as for
|
||||
example GNU General Public License (GPL), Eclipse Public License (EPL), Apache
|
||||
Software License, BSD license or MIT license.
|
||||
|
||||
6. STMicroelectronics has no obligation to provide any maintenance, support or
|
||||
updates for the software.
|
||||
|
||||
7. The software is and will remain the exclusive property of STMicroelectronics
|
||||
and its licensors. The recipient will not take any action that jeopardizes
|
||||
STMicroelectronics and its licensors' proprietary rights or acquire any rights
|
||||
in the software, except the limited rights specified hereunder.
|
||||
|
||||
8. The recipient shall comply with all applicable laws and regulations affecting
|
||||
the use of the software or any part thereof including any applicable export
|
||||
control law or regulation.
|
||||
|
||||
9. Redistribution and use of this software or any part thereof other than as
|
||||
permitted under this license is void and will automatically terminate your
|
||||
rights under this license.
|
||||
|
||||
10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE
|
||||
DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL
|
||||
STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER
|
||||
EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY
|
||||
RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY.
|
||||
|
||||
|
|
@ -0,0 +1,548 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file evision-api-awb.h
|
||||
* @author LACROIX - Impulse
|
||||
* @brief eVision Auto White Balance algorithm public header.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 LACROIX - Impulse.
|
||||
* Copyright (c) 2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef EVISION_API_AWB_H_
|
||||
#define EVISION_API_AWB_H_
|
||||
|
||||
/************************************************************************
|
||||
* Includes
|
||||
************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "evision-api-utils.h"
|
||||
|
||||
/************************************************************************
|
||||
* Public Defines
|
||||
************************************************************************/
|
||||
|
||||
/*! @brief Maximum number of supported sensor configurations. */
|
||||
#define EVISION_AWB_MAX_SENSOR_CONFIGS (2u)
|
||||
/*! @brief Default sensor configuration index. */
|
||||
#define EVISION_AWB_DEFAULT_SENSOR_CONFIG_INDEX (0u)
|
||||
/*! @brief Default number of ROIs for AWB. */
|
||||
#define EVISION_AWB_DEFAULT_NB_ROI (1u)
|
||||
/*! @brief Maximum number of AWB profiles. */
|
||||
#define EVISION_AWB_MAX_PROFILE_COUNT (5u)
|
||||
|
||||
/*! @brief Number of CFA digital gains for AWB */
|
||||
#define EVISION_AWB_NB_DG_CFA_GAINS (4u)
|
||||
/*! @brief Number of rows / columns of CCM for AWB */
|
||||
#define EVISION_AWB_CCM_SIZE (3u)
|
||||
/*! @brief Size of estimated color temperatures history. Restrictions: >= 3. */
|
||||
#define EVISION_AWB_HIST_SIZE (3u)
|
||||
/*! @brief Number of components for external measurements */
|
||||
#define EVISION_AWB_EXT_MEAS_SIZE (3u)
|
||||
|
||||
/*! @brief Flag value to indicate the use of profile selection based AWB operation mode. */
|
||||
#define EVISION_AWB_USE_PROFILE_SELECTION_AWB (1u)
|
||||
|
||||
/************************************************************************
|
||||
* Public Structures
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* @typedef evision_awb_priv_param_runtime_t
|
||||
* @brief AWB algorithm private run-time parameters, member of #evision_awb_estimator_t.
|
||||
*
|
||||
* @struct evision_awb_priv_param_runtime
|
||||
* @brief AWB algorithm private run-time parameters, member of #evision_awb_estimator_t.
|
||||
*/
|
||||
typedef struct evision_awb_priv_param_runtime {
|
||||
/*! @brief
|
||||
* Current convergence speed. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter. Must not be changed! <br/>
|
||||
* <b>Default value:</b> 1.0
|
||||
*/
|
||||
double speed_p_value;
|
||||
/*! @brief
|
||||
* Flag to indicate change in estimated AWB color temperature. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter. Must not be changed! <br/>
|
||||
* <b>Default value:</b> 0
|
||||
*/
|
||||
uint8_t temp_changed;
|
||||
/*! @brief
|
||||
* AWB internal color temperature. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter. Must not be changed! <br/>
|
||||
* <b>Default value:</b> -1.0
|
||||
*/
|
||||
double int_temp;
|
||||
/*! @brief
|
||||
* T value parameter. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter. Must not be changed! <br/>
|
||||
* <b>Default value:</b> 0.1 */
|
||||
double t_value;
|
||||
|
||||
/*! @brief
|
||||
* Flag to indicate the estimator has entered an oscillatory state. <br/>
|
||||
* <b>Restrictions:</b> >=0 AND < #EVISION_AWB_HIST_SIZE
|
||||
*/
|
||||
uint8_t oscillation;
|
||||
/*! @brief
|
||||
* History of selected profile color temperatures. <br/>
|
||||
*/
|
||||
double hist_temp_current[EVISION_AWB_HIST_SIZE];
|
||||
/*! @brief
|
||||
* History of computed color temperatures. <br/>
|
||||
*/
|
||||
double hist_temp_estim[EVISION_AWB_HIST_SIZE];
|
||||
/*! @brief
|
||||
* History of computed chromaticity stats. <br/>
|
||||
*/
|
||||
double hist_stats[EVISION_AWB_HIST_SIZE][2u];
|
||||
/*! @brief
|
||||
* Counter for the current number of items in history. <br/>
|
||||
* <b>Restrictions:</b> >=0 AND < #EVISION_AWB_HIST_SIZE
|
||||
*/
|
||||
uint16_t cnt_hist;
|
||||
|
||||
} evision_awb_priv_param_runtime_t;
|
||||
|
||||
/**
|
||||
* @typedef evision_awb_profile_t
|
||||
* @brief AWB algorithm profile definition.
|
||||
*
|
||||
* @struct evision_awb_profile
|
||||
* @brief AWB algorithm profile definition.
|
||||
*/
|
||||
typedef struct evision_awb_profile {
|
||||
/*! @brief
|
||||
* The color temperature of the illumination for which the profile is defined.
|
||||
* Positive value, typical range of values is between 2000 and 10000 °Kelvin. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter set during initialization, must not be changed during run-time. <br/>
|
||||
*/
|
||||
float color_temperature;
|
||||
/*! @brief
|
||||
* The sensor/ISP channel gains. <br/>
|
||||
* <b>Note:</b> The individual gain values are stored using the float type.
|
||||
* The gains can be stored as ratios or as floating point representations of integer values.
|
||||
* It is up to the user to convert the values to the format expected by the sensor/ISP.
|
||||
*/
|
||||
float gain_values[EVISION_AWB_NB_DG_CFA_GAINS];
|
||||
/*! @brief
|
||||
* The ISP color correction matrix coefficients. <br/>
|
||||
* <b>Note:</b> The individual color correction matrix coefficients are stored using the float type.
|
||||
* The coefficients can be stored as ratios or as a floating point representation of integer values.
|
||||
* It is up to the user to convert the values to the format expected by the sensor/ISP.
|
||||
*/
|
||||
float ccm_coefficients[EVISION_AWB_CCM_SIZE][EVISION_AWB_CCM_SIZE];
|
||||
/*! @brief
|
||||
* The ISP color correction matrix offset coefficients. <br/>
|
||||
* <b>Note:</b> The individual color correction matrix offset coefficients are stored using the float type.
|
||||
* The coefficients can be stored as ratios or as a floating point representation of integer values.
|
||||
* It is up to the user to convert the values to the format expected by the sensor/ISP.
|
||||
*/
|
||||
float ccm_offsets[EVISION_AWB_CCM_SIZE];
|
||||
} evision_awb_profile_t;
|
||||
|
||||
/**
|
||||
* @typedef evision_awb_calib_data_t
|
||||
* @brief Sensor specific AWB calibration data, member of #evision_awb_estimator_t.
|
||||
*
|
||||
* @struct evision_awb_calib_data
|
||||
* @brief Sensor specific AWB calibration data, member of #evision_awb_estimator_t.
|
||||
*
|
||||
* Contains sensor specific AWB calibration data for accurate color rendering.
|
||||
* Support for both continious AWB and profile selection based AWB.
|
||||
*
|
||||
*/
|
||||
typedef struct evision_awb_calib_data {
|
||||
/*! @brief
|
||||
* Minimum supported color temperature. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter, positive valued. Set during estimator initialization.
|
||||
*/
|
||||
double min_temp;
|
||||
/*! @brief
|
||||
* Maximum supported color temperature. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter, positive valued and > #min_temp. Set during estimator initialization.
|
||||
*/
|
||||
double max_temp;
|
||||
|
||||
/* ##############################
|
||||
Parameters for continuous AWB
|
||||
*/
|
||||
|
||||
/* #################################
|
||||
Parameters for profile based AWB
|
||||
*/
|
||||
|
||||
/*! @brief
|
||||
* Counter for the actual number of specified profiles. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter set during initialization. Must not be changed during runtime.
|
||||
* Range of possible values: > 0 and < #EVISION_AWB_MAX_PROFILE_COUNT
|
||||
*/
|
||||
uint16_t profiles_count;
|
||||
|
||||
/*! @brief
|
||||
* Array containing the color temperatures of the defined profiles. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter set during initialization. Must not be changed during runtime.
|
||||
*/
|
||||
float temperatures[EVISION_AWB_MAX_PROFILE_COUNT];
|
||||
|
||||
/*! @brief
|
||||
* Array containing the decision thresholds between the different profiles for profile selection. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter set during initialization. Must not be changed during runtime.
|
||||
*/
|
||||
float decision_thresholds[EVISION_AWB_MAX_PROFILE_COUNT - 1];
|
||||
|
||||
/*! @brief
|
||||
* Array containing the different AWB profiles. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter set during initialization. Must not be changed during runtime.
|
||||
*/
|
||||
evision_awb_profile_t profiles[EVISION_AWB_MAX_PROFILE_COUNT];
|
||||
|
||||
/*! @brief
|
||||
* Pointer to the active profile. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter updated during runtime. Code outside of the library must not alter its value.
|
||||
*/
|
||||
evision_awb_profile_t* active_profile;
|
||||
|
||||
} evision_awb_calib_data_t;
|
||||
|
||||
/**
|
||||
* @typedef evision_awb_hyper_param_t
|
||||
* @brief AWB algorithm hyper-parameters, member of #evision_awb_estimator_t.
|
||||
*
|
||||
* @struct evision_awb_hyper_param
|
||||
* @brief AWB algorithm hyper-parameters, member of #evision_awb_estimator_t.
|
||||
*
|
||||
*/
|
||||
typedef struct evision_awb_hyper_param {
|
||||
/*! @brief
|
||||
* Ratio of pixels to be processed for AWB when using the SW statistics extraction block, direct impact on processing time.
|
||||
* (Ex. A value of 2 will process 1 pixel every 2*2 pixel block in the entire ROI). <br/>
|
||||
* <b>Restrictions:</b> >= 1 AND < image_size. <br/>
|
||||
* <b>Default value:</b> 1 */
|
||||
uint16_t awb_process_ratio;
|
||||
|
||||
/*! @brief
|
||||
* AWB low luminance threshold value when using the SW statistics extraction block.
|
||||
* Skip pixel from AWB stats if luminance value below the threshold. <br/>
|
||||
* <b>Restrictions:</b> >= 0 AND < #y_thresh_high. <br/>
|
||||
* <b>Default value:</b> 0 */
|
||||
double y_thresh_low;
|
||||
/*! @brief
|
||||
* AWB high luminance threshold value when using the SW statistics extraction block.
|
||||
* Skip pixel from AWB stats if luminance value above the threshold. <br/>
|
||||
* <b>Restrictions:</b> > #y_thresh_low AND <= 255. <br/>
|
||||
* <b>Default value:</b> 0 */
|
||||
double y_thresh_high;
|
||||
|
||||
/*! @brief
|
||||
* Convergence speed increment. <br/>
|
||||
* <b>Restrictions:</b> > 0 AND < #speed_p_max. <br/>
|
||||
* <b>Default value:</b> 0.1 */
|
||||
double speed_p_increment;
|
||||
/*! @brief
|
||||
* Minimum convergence speed. <br/>
|
||||
* <b>Restrictions:</b> > 0 AND < #speed_p_max. <br/>
|
||||
* <b>Default value:</b> 1.0 */
|
||||
double speed_p_min;
|
||||
/*! @brief
|
||||
* Maximum convergence speed. <br/>
|
||||
* <b>Restrictions:</b> > #speed_p_min. <br/>
|
||||
* <b>Default value:</b> 3.0 */
|
||||
double speed_p_max;
|
||||
|
||||
/*! @brief
|
||||
* AWB color temperature estimation precision. <br/>
|
||||
* <b>Default value:</b> 1 °K */
|
||||
double precision_temp;
|
||||
|
||||
/*! @brief
|
||||
* Offset around the decision threshold for hysteresis based decision for profile selection. <br/>
|
||||
* <b>Default value:</b> 50 °K */
|
||||
float hysteresis_offset;
|
||||
|
||||
/*! @brief
|
||||
* Threshold of acceptable chromatic deviation around neutrality for convergence. <br/>
|
||||
* <b>Restrictions:</b> > 0. <br/>
|
||||
* <b>Default value:</b> 1.0. */
|
||||
float conv_criterion;
|
||||
|
||||
/*! @brief
|
||||
* Threshold of acceptable chromatic deviation along the green-magenta axis.
|
||||
* Inhibit profile switch if the green or magenta component is higher than this threshold.<br/>
|
||||
* <b>Restrictions:</b> > 0. <br/>
|
||||
* <b>Default value:</b> 0.5. */
|
||||
float gm_tolerance;
|
||||
|
||||
/*! @brief
|
||||
* Tolerance parameter to assess color temperature similarity: assume same colour temperature if absolute difference smaller than this value.
|
||||
* Parameter of the profile selection oscillation detection logic.<br/>
|
||||
* <b>Restrictions:</b> > 0 and >= 2 * #hysteresis_offset <br/>
|
||||
* <b>Default value:</b> 175 K. */
|
||||
float ct_tolerance;
|
||||
|
||||
/*! @brief
|
||||
* Tolerance parameter to assess similarity of AWB statistics: assume identical statistics if euclidean norm smaller than this value.
|
||||
* Parameter of the profile selection oscillation detection logic.<br/>
|
||||
* <b>Restrictions:</b> > 0. <br/>
|
||||
* <b>Default value:</b> 1.5. */
|
||||
float stats_tolerance;
|
||||
|
||||
} evision_awb_hyper_param_t;
|
||||
|
||||
/**
|
||||
* @typedef evision_awb_estimator_t
|
||||
* @brief AWB estimator structure.
|
||||
*
|
||||
* @struct evision_awb_estimator
|
||||
* @brief AWB estimator structure.
|
||||
*
|
||||
* Set of all data structures required for the functioning of the AWB algorithm.
|
||||
*/
|
||||
typedef struct evision_awb_estimator {
|
||||
/*! @brief
|
||||
* Indicates the state of the AWB algorithm. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter. Must not be changed! <br/>
|
||||
* Possible values: see #evision_state_t */
|
||||
evision_state_t state;
|
||||
|
||||
/*! @brief
|
||||
* Computed sensor/ISP gain values stored as float values.
|
||||
* To be applied to the sensor/ISP after conversion to the format expected by the sensor/ISP. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter. Must not be changed! <br/>
|
||||
* <b>Note:</b> Storing values as floats provides the required flexibility to support different sensors and ISPs.
|
||||
* Converting the float value to the specific sensor/ISP format is to be performed at application level.
|
||||
*/
|
||||
float dg_cf[EVISION_AWB_NB_DG_CFA_GAINS];
|
||||
/*! @brief
|
||||
* Computed ISP CCM coefficients stored as float values.
|
||||
* To be applied to the sensor/ISP after conversion to the format expected by the sensor/ISP. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter. Must not be changed! <br/>
|
||||
* <b>Note:</b> Storing values as floats provides the required flexibility to support different sensors and ISPs.
|
||||
* Converting the float value to the specific sensor/ISP format is to be performed at application level.
|
||||
*/
|
||||
float ccm[EVISION_AWB_CCM_SIZE][EVISION_AWB_CCM_SIZE];
|
||||
/*! @brief
|
||||
* Computed ISP CCM offset coefficients stored as float values.
|
||||
* To be applied to the sensor/ISP after conversion to the format expected by the sensor/ISP. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter. Must not be changed! <br/>
|
||||
* <b>Note:</b> Storing values as floats provides the required flexibility to support different sensors and ISPs.
|
||||
* Converting the float value to the specific sensor/ISP format is to be performed at application level.
|
||||
*/
|
||||
float ccm_offsets[EVISION_AWB_CCM_SIZE];
|
||||
|
||||
/*! @brief
|
||||
* Estimated color temperature. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter. Must not be changed! <br/>
|
||||
* <b>Default value:</b> 5000 °K
|
||||
*/
|
||||
double out_temp;
|
||||
|
||||
/*! @brief
|
||||
* Select the AWB operating mode. <br/>
|
||||
* <b>Restrictions:</b> Only profile selection AWB is currently supported.
|
||||
*/
|
||||
uint8_t awb_mode;
|
||||
|
||||
/*! @brief
|
||||
* The set of run-time variables. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameters.
|
||||
* Must not be changed! */
|
||||
evision_awb_priv_param_runtime_t runtime_vars;
|
||||
|
||||
/*! @brief
|
||||
* AWB calibration data. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter.
|
||||
* Must be set during initialization using the provided functions!
|
||||
* Must not be changed during runtime! */
|
||||
evision_awb_calib_data_t calib_data;
|
||||
|
||||
/*! @brief
|
||||
* The set of AWB algorithm hyper-parameters. Set to default values during initialization! <br/>
|
||||
* As a general note, the hyper-parameters can be updated from their default values.
|
||||
* Care must be taken as in such a case there is no guarantee of proper functioning of the estimator! <br/>
|
||||
* <b>Restrictions:</b> Must not be updated during runtime!
|
||||
*/
|
||||
evision_awb_hyper_param_t hyper_params;
|
||||
|
||||
/*! @brief
|
||||
* Handler to output logs. <br/> */
|
||||
evision_api_log_callback log_cb;
|
||||
|
||||
} evision_awb_estimator_t;
|
||||
|
||||
/************************************************************************
|
||||
* Public Variables
|
||||
************************************************************************/
|
||||
|
||||
/************************************************************************
|
||||
* Public Function Prototypes
|
||||
************************************************************************/
|
||||
|
||||
/************************************************************************
|
||||
* Public Function Definitions
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* @fn evision_awb_estimator_t* evision_api_awb_new(void);
|
||||
* @brief Create a new #evision_awb_estimator_t instance.
|
||||
*
|
||||
* @param[in] log_cb Callback to output logs.
|
||||
* @return The address of the created instance. NULL if it failed.
|
||||
*
|
||||
* This function performs dynamic memory allocations for the AWB estimator.
|
||||
* If the process fails, NULL is returned.
|
||||
*
|
||||
* @warning Allocates memory. Free memory with evision_api_awb_delete().
|
||||
*/
|
||||
evision_awb_estimator_t* evision_api_awb_new(evision_api_log_callback log_cb);
|
||||
|
||||
/**
|
||||
* @fn evision_return_t evision_api_awb_delete(evision_awb_estimator_t* self);
|
||||
* @brief Releases the memory allocated for the #evision_awb_estimator_t estimator instance.
|
||||
*
|
||||
* @param[in, out] self Concerned estimator instance address.
|
||||
* @return
|
||||
* - EVISION_RET_SUCCESS
|
||||
* - EVISION_RET_PARAM_ERR
|
||||
*
|
||||
* This function releases the memory allocated for an AWB estimator.
|
||||
* To be called when the estimator is no longer required.
|
||||
*/
|
||||
evision_return_t evision_api_awb_delete(evision_awb_estimator_t* self);
|
||||
|
||||
/**
|
||||
* @brief Set the parameters of the input AWB profile structure.
|
||||
*
|
||||
* @param[in, out] awb_profile AWB profile structure.
|
||||
* @param[in] color_temperature Color temperature of the illumination used to derive the profile parameters.
|
||||
* @param[in] cfa_gains Array containing the sensor/ISP channel gains.
|
||||
* @param[in] ccm_coefficients Matrix containing the color correction matrix coefficients.
|
||||
* @param[in] ccm_offsets Array containing the color correction matrix offsets.
|
||||
*
|
||||
*/
|
||||
void evision_api_awb_set_profile(evision_awb_profile_t* awb_profile,
|
||||
float color_temperature, const float cfa_gains[EVISION_AWB_NB_DG_CFA_GAINS],
|
||||
const float ccm_coefficients[EVISION_AWB_CCM_SIZE][EVISION_AWB_CCM_SIZE],
|
||||
const float ccm_offsets[EVISION_AWB_CCM_SIZE]);
|
||||
|
||||
/**
|
||||
* @brief Initialize the AWB profiles from user supplied data.
|
||||
* The library supports a variable number of profiles from a minimum of 1 up to a max number of #EVISION_AWB_MAX_PROFILE_COUNT.
|
||||
*
|
||||
* @param[in, out] self AWB estimator to be initialized.
|
||||
* @param[in] min_temp Minimum supported color temperature, positive value.
|
||||
* @param[in] max_temp Maximum supported color temperature, positive value and greater than min_temp.
|
||||
* @param[in] nb_profiles The number of defined profiles, between 1 and #EVISION_AWB_MAX_PROFILE_COUNT.
|
||||
* @param[in] decision_thresholds The decision thresholds between profiles in degrees Kelvin. A total of nb_profiles - 1 decision thresholds must be provided.
|
||||
* @param[in] awb_profiles Array of profile data, a total of nb_profiles must be provided.
|
||||
* @return
|
||||
* - EVISION_RET_SUCCESS
|
||||
* - EVISION_RET_PARAM_ERR
|
||||
* - EVISION_RET_FAILURE
|
||||
*
|
||||
* The min_temp parameter must be at most equal to the smallest color temperature of the defined profiles.
|
||||
* The max_temp parameter must be at least equal to the highest color temperature of the defined profiles.
|
||||
*
|
||||
* The profiles must be unique with respect to the color temperature of the illumination and must be specified in ascending order.
|
||||
* The choice of the actual number of profiles and the color temperature of the illumination for each profile is
|
||||
* generally dependent on the intended application and/or the available hardware equipement for generating the calibration data.
|
||||
* They must be complete in the sense that they must contain all the required fields (channel gains and color correction coefficients).
|
||||
* It is the user's responsibility to ensure that this is indeed the case.
|
||||
*
|
||||
* The decision thresholds must be unique and specified in ascending order.
|
||||
* Between each pair of adjacent profiles there must be exactly one decision threshold.
|
||||
* The exact strategy for choosing the decision thresholds between adjacent thresholds (e.g. halfway, 1/3 - 2/3, etc.)
|
||||
* is a tuning strategy which generally depends on the intended application and the choice of the profiles.
|
||||
*
|
||||
*/
|
||||
evision_return_t evision_api_awb_init_profiles(evision_awb_estimator_t* const self,
|
||||
double min_temp, double max_temp,
|
||||
uint16_t nb_profiles, float decision_thresholds[EVISION_AWB_MAX_PROFILE_COUNT - 1],
|
||||
evision_awb_profile_t awb_profiles[EVISION_AWB_MAX_PROFILE_COUNT]);
|
||||
|
||||
/**
|
||||
* @brief Run the AWB estimator on the full frame data.
|
||||
*
|
||||
* @param[in] self Concerned estimator instance address.
|
||||
* @param[in] image Current frame.
|
||||
* @param[in] use_ext_meas Flag to indicate the use of external AWB measurement: 0 - use internal AWB measurement, > 0 - use external measurement.
|
||||
* @param[in] ext_meas External measurement vector, contains average R, G, B values.
|
||||
* @return
|
||||
* - EVISION_RET_INVALID_VALUE
|
||||
* - EVISION_RET_SUCCESS
|
||||
* - EVISION_RET_PARAM_ERROR
|
||||
* - EVISION_RET_FAILURE
|
||||
*
|
||||
* Run an execution of the control loop on the current camera setup and frame.
|
||||
* The parameters #evision_awb_estimator_t.ccm and #evision_awb_estimator_t.dg_cf are updated to reflect the new CCMs and channel gains to apply.
|
||||
*
|
||||
* The software statistics extraction block, if used, will consider the entire data frame in the extraction of the AWB statistics.
|
||||
* The parameter #evision_awb_hyper_param_t.awb_process_ratio defines a ratio of pixels to check PER row and PER column.
|
||||
* It serves to reduce the computational requirements for AWB statistics extraction.
|
||||
* For example: a process_ratio of 4 means that for every 4 pixels per row and per column, (block of 16 pixels) only 1 is considered.
|
||||
* For small to moderate values, the loss in accuracy is mostly negligeable with non-negligeable improvements in computational time.
|
||||
*
|
||||
* The average R, G, and B values provided by the external \[hardware\] measurement block must be in the range \[0, 255\].
|
||||
* If the data is in a different range, the average values must be converted to this range before being passed as parameters to the function.
|
||||
*
|
||||
* The switch at run-time between using the internal software measurements and the external \[hardware\] measurements is not supported.
|
||||
*
|
||||
* <b>Raises:</b>
|
||||
* - EVISION_LOGSEV_INFO
|
||||
* - EVISION_LOGSEV_WARNING
|
||||
* - EVISION_LOGSEV_ERROR
|
||||
*/
|
||||
evision_return_t evision_api_awb_run_average(evision_awb_estimator_t* const self, const evision_image_t* const image,
|
||||
uint8_t use_ext_meas, double ext_meas[EVISION_AWB_EXT_MEAS_SIZE]);
|
||||
|
||||
#ifdef ALGO_SW_STATISTICS
|
||||
/**
|
||||
* @brief Run the AWB estimator on the selected ROIs.
|
||||
*
|
||||
* @param[in] self Concerned estimator instance address.
|
||||
* @param[in] image Current frame.
|
||||
* @param[in] roi_array Set of ROIs where the process will be applied, other regions will not be considered.
|
||||
* @param[in] use_ext_meas Flag to indicate the use of external AWB measurement: 0 - use internal AWB measurement, > 0 - use external measurement.
|
||||
* @param[in] ext_meas External measurement vector, contains average R, G, B values.
|
||||
* @return
|
||||
* - EVISION_RET_INVALID_VALUE
|
||||
* - EVISION_RET_SUCCESS
|
||||
* - EVISION_RET_PARAM_ERROR
|
||||
* - EVISION_RET_FAILURE
|
||||
*
|
||||
* Run an execution of the control loop on the current camera setup and frame.
|
||||
* The parameters #evision_awb_estimator_t.ccm and #evision_awb_estimator_t.dg_cf are updated to reflect the new CCMs and channel gains to apply.
|
||||
*
|
||||
* The software statistics extraction block, if used, will only considered the pixels within the specified ROIs.
|
||||
* The parameter #evision_awb_hyper_param_t.awb_process_ratio defines, within the ROI to check, a portion of pixels to check PER row and PER column.
|
||||
* It serves to reduce the computational requirements for AWB statistics extraction.
|
||||
* For example: a process_ratio of 4 means that for every 4 pixels per row and per column, (block of 16 pixels) only 1 is considered.
|
||||
* For small to moderate values, the loss in accuracy is mostly negligeable with non-negligeable improvements in computational time.
|
||||
*
|
||||
* The average R, G, and B values provided by the external \[hardware\] measurement block must be in the range \[0, 255\].
|
||||
* If the data is in a different range, the average values must be converted to this range before being passed as parameters to the function.
|
||||
*
|
||||
* The switch at run-time between using the internal software measurements and the external \[hardware\] measurements is not supported.
|
||||
*
|
||||
* <b>Raises:</b>
|
||||
* - EVISION_LOGSEV_INFO
|
||||
* - EVISION_LOGSEV_WARNING
|
||||
* - EVISION_LOGSEV_ERROR
|
||||
*/
|
||||
evision_return_t evision_api_awb_run_roi(evision_awb_estimator_t* const self,
|
||||
const evision_image_t* const image, const evision_roi_array_t* const roi_array,
|
||||
uint8_t use_ext_meas, double ext_meas[EVISION_AWB_EXT_MEAS_SIZE]);
|
||||
#endif
|
||||
|
||||
#endif /* EVISION_API_AWB_H_ */
|
||||
|
|
@ -0,0 +1,228 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file evision-api-st-ae.h
|
||||
* @author STMicroelectronics / LACROIX - Impulse
|
||||
* @brief ST eVision Auto Exposure algorithm public header.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2025 STMicroelectronics.
|
||||
* Copyright (c) 2023 LACROIX - Impulse.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef EVISION_API_ST_AE_H_
|
||||
#define EVISION_API_ST_AE_H_
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include "evision-api-utils.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef struct evision_st_ae_hyper_param {
|
||||
/*! @brief
|
||||
* Target exposure to reach. <br/>
|
||||
* <b>Restrictions:</b> >= 0 AND < 256. <br/>
|
||||
* <b>Default value:</b> 56 */
|
||||
uint32_t target;
|
||||
/*! @brief
|
||||
* Max delta between lum stat and target in convergence region <br/>
|
||||
* <b>Restrictions:</b> >= 0 AND < 256. <br/>
|
||||
* <b>Default value:</b> 10 */
|
||||
uint32_t tolerance;
|
||||
/*! @brief
|
||||
* Factor applied to increment gain update <br/>
|
||||
* <b>Restrictions:</b> >= 0 AND < 1000. <br/>
|
||||
* <b>Default value:</b> 100 */
|
||||
uint32_t gain_increment_coeff;
|
||||
/*! @brief
|
||||
* Max delta value between lum stat and target in low delta region <br/>
|
||||
* <b>Restrictions:</b> >= 0 AND < 256. <br/>
|
||||
* <b>Default value:</b> 45 */
|
||||
uint32_t gain_low_delta;
|
||||
/*! @brief
|
||||
* Min delta value between lum stat and target in high delta region <br/>
|
||||
* <b>Restrictions:</b> >= 0 AND < 256. <br/>
|
||||
* <b>Default value:</b> 120 */
|
||||
uint32_t gain_high_delta;
|
||||
/*! @brief
|
||||
* Maximum gain update value in luminance low delta region <br/>
|
||||
* <b>Restrictions:</b> >= #gain_min AND < #gain_max. <br/>
|
||||
* <b>Default value:</b> 1500 */
|
||||
uint32_t gain_low_increment_max;
|
||||
/*! @brief
|
||||
* Maximum gain update value in luminance medium delta region <br/>
|
||||
* <b>Restrictions:</b> >= #gain_min AND < #gain_max. <br/>
|
||||
* <b>Default value:</b> 6000 */
|
||||
uint32_t gain_medium_increment_max;
|
||||
/*! @brief
|
||||
* Maximum gain update value in luminance high delta region <br/>
|
||||
* <b>Restrictions:</b> >= #gain_min AND < #gain_max. <br/>
|
||||
* <b>Default value:</b> 12000 */
|
||||
uint32_t gain_high_increment_max;
|
||||
/*! @brief
|
||||
* Factor applied to increment exposure <br/>
|
||||
* <b>Restrictions:</b> >= 0.0 AND < 1. <br/>
|
||||
* <b>Default value:</b> 0.020*/
|
||||
double exposure_up_ratio;
|
||||
/*! @brief
|
||||
* Minimum value accepted for exposure time. <br/>
|
||||
* <b>Restrictions:</b> >= 0.0 AND < 1. <br/>
|
||||
* <b>Default value:</b> 0.004*/
|
||||
double exposure_down_ratio;
|
||||
/*! @brief
|
||||
* Minimum value accepted for exposure time. <br/>
|
||||
* <b>Restrictions:</b> >= 0.0 AND < #exposure_max. <br/>
|
||||
* <b>Default value:</b> 0.0*/
|
||||
uint32_t exposure_min;
|
||||
/*! @brief
|
||||
* Maximum value accepted for exposure time. <br/>
|
||||
* <b>Restrictions:</b> > 0.0 AND >= #exposure_min. <br/>
|
||||
* <b>Default value:</b> 1.0 */
|
||||
uint32_t exposure_max;
|
||||
/*! @brief
|
||||
* Minimum possible gain value. <br/>
|
||||
* <b>Restrictions:</b> > 1 AND < #gain_max. <br/>
|
||||
* <b>Default value:</b> 1 */
|
||||
uint32_t gain_min;
|
||||
/*! @brief
|
||||
* Maximum possible gain value. <br/>
|
||||
* <b>Restrictions:</b> >= 1 AND > #gain_min. <br/>
|
||||
* <b>Default value:</b> 1 */
|
||||
uint32_t gain_max;
|
||||
/*! @brief
|
||||
* Luminance limit where we consider the frame as dark. <br/>
|
||||
* <b>Restrictions:</b> >= 0 AND < 256. <br/>
|
||||
* <b>Default value:</b> 5 */
|
||||
uint32_t dark_zone_lum_limit;
|
||||
/*! @brief
|
||||
* Compatible light frequency in Hz to avoid flickering effect. <br/>
|
||||
* <b>Restrictions:</b> >= 0 (None) AND < 256. <br/>
|
||||
* <b>Default value:</b> 0 (None) */
|
||||
uint32_t compat_freq;
|
||||
|
||||
} evision_st_ae_hyper_param_t;
|
||||
|
||||
/**
|
||||
* @typedef evision_ae_estimator_t
|
||||
* @brief AE estimator structure.
|
||||
*
|
||||
* @struct evision_ae_estimator
|
||||
* @brief AE estimator structure.
|
||||
*
|
||||
* Set of all data structures required for the functioning of the AE algorithm.
|
||||
*/
|
||||
typedef struct evision_st_ae_process_t {
|
||||
/*! @brief
|
||||
* Indicates the state of the AE algorithm. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter. Must not be changed! <br/>
|
||||
* Possible values: see #evision_state_t */
|
||||
evision_state_t state;
|
||||
/*! @brief
|
||||
* Computed exposure time to apply to sensor. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter. Must not be changed! */
|
||||
uint32_t new_exposure;
|
||||
|
||||
/*! @brief
|
||||
* Computed gain value to apply to sensor. <br/>
|
||||
* <b>Restrictions:</b> Internal algorithm parameter. Must not be changed! */
|
||||
uint32_t new_gain;
|
||||
|
||||
/*! @brief
|
||||
* The set of AE algorithm hyper-parameters. Set to default values at creation! <br/>
|
||||
* #evision_ae_hyper_param_t.exposure_min, #evision_ae_hyper_param_t.exposure_max,
|
||||
* #evision_ae_hyper_param_t.gain_min and #evision_ae_hyper_param_t.gain_max hyper-parameters
|
||||
* <b> must be updated </b> before running the ae process with respect to the sensor in use. <br/>
|
||||
* As a general note, the hyper-parameters can be updated from their default values.
|
||||
* Care must be taken as in such a case there is no guarantee of proper functioning of the process! <br/>
|
||||
* <b>Restrictions:</b> Must not be updated during runtime!
|
||||
*/
|
||||
evision_st_ae_hyper_param_t hyper_params;
|
||||
|
||||
/*! @brief
|
||||
* Handler to output logs. <br/> */
|
||||
evision_api_log_callback log_cb;
|
||||
|
||||
} evision_st_ae_process_t;
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define EVISION_ST_AEC_LUM_TARGET 56 /* Default luminance value targeted by the AE algorithm */
|
||||
#define EVISION_ST_AEC_TOLERANCE 10 /* Max delta between lum stat and target in convergence region */
|
||||
#define EVISION_ST_AEC_GAIN_INCREMENT_COEFF 100 /* Factor applied to increment gain update */
|
||||
#define EVISION_ST_AEC_GAIN_LOW_DELTA 45 /* Max delta value between lum stat and target in low delta region */
|
||||
#define EVISION_ST_AEC_GAIN_HIGH_DELTA 120 /* Min delta value between lum stat and target in high delta region */
|
||||
#define EVISION_ST_AEC_GAIN_LOW_INC_MAX 1500 /* Maximum gain update value in luminance low delta region */
|
||||
#define EVISION_ST_AEC_GAIN_MEDIUM_INC_MAX 6000 /* Maximum gain update value in luminance medium delta region */
|
||||
#define EVISION_ST_AEC_GAIN_HIGH_INC_MAX 12000 /* Maximum gain update value in luminance high delta region */
|
||||
#define EVISION_ST_AEC_EXPOSURE_UP_RATIO 0.020F /* Factor applied to increment exposure */
|
||||
#define EVISION_ST_AEC_EXPOSURE_DOWN_RATIO 0.004F /* Factor applied to decrement exposure */
|
||||
#define EVISION_ST_AEC_DARKZONE_LUM_LIMIT 5 /* Default value for dark zone luminance limit */
|
||||
#define EVISION_ST_DEFAULT_EXPOSURE_MIN 0 /* Default value for exposure min */
|
||||
#define EVISION_ST_DEFAULT_EXPOSURE_MAX 33000 /* Default value for expsoure max */
|
||||
#define EVISION_ST_DEFAULT_GAIN_MIN 1 /* Default value for gain min */
|
||||
#define EVISION_ST_DEFAULT_GAIN_MAX 100 /* Default value for gain max */
|
||||
#define EVISION_ST_DEFAULT_COMPAT_FREQ 0 /* Default value for compatible frequency */
|
||||
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
/**
|
||||
* @fn evision_st_ae_process_t* evision_api_st_ae_new(void);
|
||||
* @brief Create a new #evision_st_ae_process_t instance.
|
||||
*
|
||||
* @param[in] log_cb Callback to output logs.
|
||||
* @return The address of the created instance. NULL if it failed.
|
||||
*/
|
||||
evision_st_ae_process_t* evision_api_st_ae_new(evision_api_log_callback log_cb);
|
||||
|
||||
/**
|
||||
* @fn evision_return_t evision_api_st_ae_delete(evision_st_ae_process_t* self);
|
||||
* @brief Releases the memory allocated for the #evision_st_ae_process_t ae process instance.
|
||||
*
|
||||
* @param[in, out] ae process instance address.
|
||||
* @return
|
||||
* - EVISION_RET_SUCCESS
|
||||
* - EVISION_RET_PARAM_ERR
|
||||
|
||||
*/
|
||||
evision_return_t evision_api_st_ae_delete(evision_st_ae_process_t* self);
|
||||
|
||||
/**
|
||||
* @fn evision_return_t evision_api_st_ae_init(evision_st_ae_process_t* const self)
|
||||
* @brief Initialize the AE process structure.
|
||||
*
|
||||
* @param[in, out] self AE process to be initialized.
|
||||
* @return
|
||||
* - EVISION_RET_SUCCESS
|
||||
* - EVISION_RET_PARAM_ERROR
|
||||
*
|
||||
* Initializes the AE process structure. Hyper params can later be modified.
|
||||
*/
|
||||
evision_return_t evision_api_st_ae_init(evision_st_ae_process_t* const self);
|
||||
|
||||
/**
|
||||
* @fn evision_return_t evision_api_st_ae_process(evision_st_ae_process_t* const self, uint32t_t current_gain, uint32_t current_exposure, uint8_t average_lum)
|
||||
* @brief Run the ae process to calculate new gain and expsoure
|
||||
*
|
||||
* @param[in, out] self Concerned process instance address.
|
||||
* @param[in] current_gain Current sensor gain in mdB.
|
||||
* @param[in] current_exposure Current sensor exposure microsecond.
|
||||
* @param[in] average_lum Average luminance measurement value. Range should normally be between 0 (completely dark image) and 255 (completely white image).
|
||||
*
|
||||
* @return
|
||||
* - EVISION_RET_SUCCESS
|
||||
* - EVISION_RET_FAILURE
|
||||
*/
|
||||
evision_return_t evision_api_st_ae_process(evision_st_ae_process_t* const self, uint32_t current_gain, uint32_t current_exposure, uint8_t average_lum);
|
||||
|
||||
/* Exported variables --------------------------------------------------------*/
|
||||
|
||||
#endif /* EVISION_API_ST_AE_H_ */
|
||||
|
|
@ -0,0 +1,326 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file evision-api-utils.h
|
||||
* @author LACROIX - Impulse
|
||||
* @brief eVision utilitary public header.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2023 LACROIX - Impulse.
|
||||
* Copyright (c) 2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef EVISION_API_UTILS_H_
|
||||
#define EVISION_API_UTILS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Includes
|
||||
************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/************************************************************************
|
||||
* Public Defines
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* @def EVISION_MIN
|
||||
* @brief Determine the lowest value between a and b
|
||||
*/
|
||||
#define EVISION_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
/**
|
||||
* @def EVISION_MAX
|
||||
* @brief Determine the greatest value between a and b
|
||||
*/
|
||||
#define EVISION_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
/**
|
||||
* @def EVISION_SIGN
|
||||
* @brief Determine the sign of a number.
|
||||
*/
|
||||
#define EVISION_SIGN(x) ((x) > 0.0f ? 1.0f : -1.0f)
|
||||
|
||||
#ifdef ALGO_SW_STATISTICS
|
||||
/* YUV parameters */
|
||||
/*! @brief Minimum of Y value due to ISP RGB 2 YUV conversion formula */
|
||||
#define EVISION_YUV_MIN_Y_VAL (16.0)
|
||||
/*! @brief Maximum of Y value due to ISP RGB 2 YUV conversion formula */
|
||||
#define EVISION_YUV_MAX_Y_VAL (235.140625)
|
||||
/*! @brief YUV factor value due to ISP RGB 2 YUV conversion formula */
|
||||
#define EVISION_YUV_FACTOR (256)
|
||||
/*! @brief YUV maximum value due to ISP RGB 2 YUV conversion formula */
|
||||
#define EVISION_YUV_MAX_VAL (255)
|
||||
/*! @brief range of Y value due to ISP RGB 2 YUV conversion formula */
|
||||
#define EVISION_YUV_RANGE_Y_VAL (EVISION_YUV_MAX_Y_VAL - EVISION_YUV_MIN_Y_VAL)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @typedef evision_return_t
|
||||
* @brief Return type for functions.
|
||||
*
|
||||
* @enum evision_return
|
||||
* @brief Return type for functions.
|
||||
*
|
||||
* Return code that must be checked to be sure the output of the function is valid.
|
||||
*/
|
||||
typedef enum evision_return {
|
||||
EVISION_RET_INVALID_VALUE = 2, /*!< The process succeeded but the output value is invalid and should not be used.*/
|
||||
EVISION_RET_SUCCESS = 1, /*!< the process succeeded. */
|
||||
EVISION_RET_FAILURE = 0, /*!< Error: There was a failure. */
|
||||
EVISION_RET_PARAM_ERR = -1, /*!< Error: A parameter is invalid. */
|
||||
EVISION_RET_DIMENSION_ERR = -2, /*!< Error: A dimension is incompatible with the process. */
|
||||
EVISION_RET_MEMORY_ERR = -3, /*!< Error: Could not allocate memory. */
|
||||
EVISION_RET_FILE_ERR = -4, /*!< Error: A file could not be opened */
|
||||
EVISION_RET_FORMAT_ERR = -5, /*!< Error: the specified format is invalid. */
|
||||
} evision_return_t;
|
||||
|
||||
/**
|
||||
* @typedef evision_state_t
|
||||
* @brief Describes the state of the estimator.
|
||||
*
|
||||
* @enum evision_state
|
||||
* @brief Describes the state of the estimator.
|
||||
*/
|
||||
typedef enum evision_state {
|
||||
/*! @brief
|
||||
* The estimator exists.
|
||||
*/
|
||||
EVISION_STATE_NONE = 0u,
|
||||
/*! @brief
|
||||
* The estimator was initialized and is ready to run.
|
||||
*/
|
||||
EVISION_STATE_INIT = 1u,
|
||||
/*! @brief
|
||||
* The estimator is running.
|
||||
*/
|
||||
EVISION_STATE_RUN = 2u,
|
||||
} evision_state_t;
|
||||
|
||||
/**
|
||||
* @typedef evision_image_format_t
|
||||
* @brief Specify the format under which the image is stored.
|
||||
*
|
||||
* @enum evision_image_format
|
||||
* @brief Specify the format under which the image is stored.
|
||||
*
|
||||
* Those formats are as the ones defined by V4L2.
|
||||
*/
|
||||
typedef enum evision_image_format {
|
||||
/*! @brief
|
||||
* 8 bit gray-level.
|
||||
*/
|
||||
EVISION_IMAGE_FORMAT_GRAY8 = 0u,
|
||||
/*! @brief
|
||||
* 8 bit gray-level.
|
||||
*/
|
||||
EVISION_IMAGE_FORMAT_GREY8 = 1u,
|
||||
/*! @brief
|
||||
* RGB interleaved, 8 bit per channel, 24 bit per pixel..
|
||||
*/
|
||||
EVISION_IMAGE_FORMAT_RGB8 = 2u,
|
||||
/*! @brief
|
||||
* BGR interleaved, 8 bit per channel, 24 bit per pixel..
|
||||
*/
|
||||
EVISION_IMAGE_FORMAT_BGR8 = 3u,
|
||||
/*! @brief
|
||||
* 8 bit YUV 422 SP format.
|
||||
*/
|
||||
EVISION_IMAGE_FORMAT_YUV422SP = 4u,
|
||||
/*! @brief
|
||||
* RGGB Bayer format, 8 bit per channel, Red compound first.
|
||||
*/
|
||||
EVISION_IMAGE_FORMAT_RGGB8 = 5u,
|
||||
/*! @brief
|
||||
* BGGR Bayer format, 8 bit per channel, Blue compound first.
|
||||
*/
|
||||
EVISION_IMAGE_FORMAT_BGGR8 = 6u,
|
||||
/*! @brief
|
||||
* GRBG Bayer format, 16 bit per channel, each coded on 16 bits inverted (0xFF, 0x0F).
|
||||
*/
|
||||
EVISION_IMAGE_FORMAT_GRBG12 = 7u,
|
||||
/*! @brief
|
||||
* RGGB Bayer format, 16 bit per channel, each coded on 16 bits inverted (0xFF, 0x0F).
|
||||
*/
|
||||
EVISION_IMAGE_FORMAT_RGGB12 = 8u
|
||||
} evision_image_format_t;
|
||||
|
||||
/************************************************************************
|
||||
* Public Functions Signatures
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief Callback function to output logs.
|
||||
*
|
||||
* @param[in] msg Received message.
|
||||
*
|
||||
* If the user wants to handle the log and messages yielded by the estimator,
|
||||
* a function with this signature must be specified.
|
||||
*
|
||||
*/
|
||||
typedef void (*evision_api_log_callback)(const char* const msg);
|
||||
|
||||
/************************************************************************
|
||||
* Public Structures
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* @typedef evision_image_t
|
||||
* @brief Structure to hold frame data and metadata for eVision AE and AWB algorithms.
|
||||
*
|
||||
* @struct evision_image
|
||||
* @brief Structure to hold frame data and metadata for eVision AE and AWB algorithms.
|
||||
*
|
||||
*/
|
||||
typedef struct evision_image {
|
||||
/*! @brief
|
||||
* Frame data.
|
||||
*/
|
||||
uint8_t* pdata;
|
||||
/*! @brief
|
||||
* Number of pixels columns in the image.
|
||||
*/
|
||||
uint16_t width;
|
||||
/*! @brief
|
||||
* Number of pixels rows in the image.
|
||||
*/
|
||||
uint16_t height;
|
||||
/*! @brief
|
||||
* The format of the image.
|
||||
*/
|
||||
evision_image_format_t format;
|
||||
} evision_image_t;
|
||||
|
||||
#ifdef ALGO_SW_STATISTICS
|
||||
/**
|
||||
* @typedef evision_roi_t
|
||||
* @brief Represents a Region Of Interest (aka a rectangle of pixels in an image).
|
||||
*
|
||||
* @struct evision_roi
|
||||
* @brief Represents a Region Of Interest (aka a rectangle of pixels in an image).
|
||||
*
|
||||
* A ROI serves to limit the statistics extraction to a specific zone inside the frame.
|
||||
* Several ROIs can be defined and for each ROI a weight must be defined.
|
||||
* The aggregated statistic is the weighted average of individual ROI statistics.
|
||||
* Setting all weights equal results in the aggregated statistic to be the arithmetic average of the individual statistics.
|
||||
*
|
||||
*/
|
||||
typedef struct evision_roi {
|
||||
/*! @brief
|
||||
* Horizontal pixel coordinate of the Top-Left corner of the ROI.
|
||||
*/
|
||||
uint16_t x0;
|
||||
/*! @brief
|
||||
* Vertical pixel coordinate of the Top-Left corner of the ROI.
|
||||
*/
|
||||
uint16_t y0;
|
||||
/*! @brief
|
||||
* Horizontal pixel coordinate of the Bottom-Right corner of the ROI.
|
||||
*/
|
||||
uint16_t x1;
|
||||
/*! @brief
|
||||
* Vertical pixel coordinate of the Bottom-Right corner of the ROI.
|
||||
*/
|
||||
uint16_t y1;
|
||||
/*! @brief
|
||||
* Weight associated to the ROI.
|
||||
*/
|
||||
double weight;
|
||||
} evision_roi_t;
|
||||
|
||||
/**
|
||||
* @typedef evision_roi_array_t
|
||||
* @brief Represents an array of evision_roi.
|
||||
*
|
||||
* @struct evision_roi_array
|
||||
* @brief Represents an array of evision_roi.
|
||||
*
|
||||
* Represents the collection of all the defined ROIs for the estimator. Must contain at least one ROI.
|
||||
*
|
||||
*/
|
||||
typedef struct evision_roi_array {
|
||||
/*! @brief
|
||||
* Pointer to the beginning of the array.
|
||||
*/
|
||||
evision_roi_t* parray;
|
||||
/*! @brief
|
||||
* Number of elements in the array.
|
||||
*/
|
||||
uint16_t len;
|
||||
} evision_roi_array_t;
|
||||
#endif
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Private Structure Declaration
|
||||
************************************************************************/
|
||||
|
||||
/************************************************************************
|
||||
* Public Variables
|
||||
************************************************************************/
|
||||
|
||||
/************************************************************************
|
||||
* Public Function Prototypes
|
||||
************************************************************************/
|
||||
|
||||
/* Library management functions */
|
||||
#ifdef ALGO_SW_STATISTICS
|
||||
/* ROI array management */
|
||||
|
||||
/**
|
||||
* @fn evision_roi_array_t* evision_api_roi_array_new(const uint16_t length)
|
||||
* @brief Create and allocate the memory for a new array of #evision_roi_array_t elements.
|
||||
*
|
||||
* @param[in] length Size of the array to create
|
||||
* @return Address of the created #evision_roi_array_t. NULL if something went wrong.
|
||||
*/
|
||||
evision_roi_array_t* evision_api_roi_array_new(const uint16_t length);
|
||||
|
||||
/**
|
||||
* @fn evision_roi_array_t* evision_api_roi_array_new_grid(const uint16_t frame_width, const uint16_t frame_height, const uint16_t roi_width, const uint16_t roi_height, const uint16_t nb_roi_col, const uint16_t nb_roi_row)
|
||||
* @brief Create and allocate the memory for a new array of #evision_roi_array_t with pre filled ROIs positioned as a grid.
|
||||
*
|
||||
* In the end, the number of ROIs will be nb_roi_col * nb_roi_row
|
||||
*
|
||||
* @param[in] frame_width Number of pixels column in the frame where the ROIs will be placed.
|
||||
* @param[in] frame_height Number of pixels rows in the frame where the ROIs will be placed.
|
||||
* @param[in] roi_width Size (columns) of each ROI.
|
||||
* @param[in] roi_height Size (rows) of each ROI.
|
||||
* @param[in] nb_roi_col Number of ROIs to be placed in the horizontal dimension.
|
||||
* @param[in] nb_roi_row Number of ROIs to be placed in the vertical dimension.
|
||||
* @return Address of the created #evision_roi_array_t. NULL if something went wrong.
|
||||
*/
|
||||
evision_roi_array_t* evision_api_roi_array_new_grid(const uint16_t frame_width, const uint16_t frame_height, const uint16_t roi_width, const uint16_t roi_height, const uint16_t nb_roi_col, const uint16_t nb_roi_row);
|
||||
|
||||
/**
|
||||
* @fn evision_return_t evision_api_roi_array_delete(evision_roi_array_t* self)
|
||||
* @brief Free the memory allocated to an #evision_roi_array_t.
|
||||
*
|
||||
* @param[in, out] self Address of the concerned ROI array instance to be deleted, cannot be used after.
|
||||
* @return
|
||||
* - EVISION_RET_SUCCESS
|
||||
* - EVISION_RET_PARAM_ERR
|
||||
*/
|
||||
evision_return_t evision_api_roi_array_delete(evision_roi_array_t* self);
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* Public Function Definitions
|
||||
************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EVISION_API_UTILS_H_ */
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue