32 #define MAX_HIST_Y 255
35 #ifndef BEBOP_AE_AWB_VERBOSE
36 #define BEBOP_AE_AWB_VERBOSE 0
40 #define PRINT(string,...) fprintf(stderr, "[bebop_ae_awb->%s()] " string,__FUNCTION__ , ##__VA_ARGS__)
42 #if BEBOP_AE_AWB_VERBOSE
44 #define VERBOSE_PRINT PRINT
46 #define VERBOSE_PRINT(...)
50 #ifndef BEBOP_AE_AWB_NICE
51 #define BEBOP_AE_AWB_NICE 5
54 #ifndef BEBOP_AUTO_EXPOSURE
55 #define BEBOP_AUTO_EXPOSURE true
59 #ifndef BEBOP_AE_EXPOSURE_GAIN
60 #define BEBOP_AE_EXPOSURE_GAIN 0.8
65 #ifndef BEBOP_AE_MIDDLE_INDEX
66 #define BEBOP_AE_MIDDLE_INDEX 160
71 #ifndef BEBOP_AE_DARK_IGNORE
72 #define BEBOP_AE_DARK_IGNORE 0.4
77 #ifndef BEBOP_AE_BRIGHT_IGNORE
78 #define BEBOP_AE_BRIGHT_IGNORE 0.2
83 #ifndef BEBOP_AE_DARK_BINS
84 #define BEBOP_AE_DARK_BINS 80
89 #ifndef BEBOP_AE_BRIGHT_BINS
90 #define BEBOP_AE_BRIGHT_BINS 20
94 #ifndef BEBOP_AUTO_WHITE_BALANCE
95 #define BEBOP_AUTO_WHITE_BALANCE true
99 #ifndef BEBOP_AWB_MIN_GAINS
100 #define BEBOP_AWB_MIN_GAINS 1.0
105 #ifndef BEBOP_AWB_MAX_GAINS
106 #define BEBOP_AWB_MAX_GAINS 63.5
111 #ifndef BEBOP_AWB_GAIN
112 #define BEBOP_AWB_GAIN 0.5
117 #ifndef BEBOP_AWB_GAIN_SCHEDULING
118 #define BEBOP_AWB_GAIN_SCHEDULING false
123 #ifndef BEBOP_AWB_GAIN_SCHEDULING_TARGET
124 #define BEBOP_AWB_GAIN_SCHEDULING_TARGET 10.0
129 #ifndef BEBOP_AWB_GAIN_SCHEDULING_TOLERANCE
130 #define BEBOP_AWB_GAIN_SCHEDULING_TOLERANCE 7.5
135 #ifndef BEBOP_AWB_GAIN_SCHEDULING_STEP
136 #define BEBOP_AWB_GAIN_SCHEDULING_STEP 0.02
141 #ifndef BEBOP_AWB_MIN_GREY_PIXELS
142 #define BEBOP_AWB_MIN_GREY_PIXELS 1000
156 float dt = (img->
pprz_ts - prev_time) * 1e-6f;
175 static float prev_real_exposure = 0.f;
176 static uint8_t prev_exposure_stuck = 0;
192 if (bright_index < MIN_HIST_Y || bright_index >
MAX_HIST_Y) {
193 bright_index = dark_index;
198 cdf[bright_index - 1] - cdf[dark_index] +
205 while (current_pixels < median_pixels && ae_current_ind <
MAX_HIST_Y) {
207 if (ae_current_ind <= dark_index) {
210 }
else if (ae_current_ind >= bright_index) {
219 float ae_current_level = (float)ae_current_ind;
222 ae_current_level -= (current_pixels - median_pixels) / (
float)yuv_stats.
ae_histogram_Y[ae_current_ind];
231 float adjustment = 1.f;
232 if (ae_current_level > 1e-5) {
234 Bound(adjustment, 1 / 16.f, 16.f);
244 prev_exposure_stuck++;
253 prev_exposure_stuck = 0;
#define VERBOSE_PRINT(...)
#define BEBOP_AE_BRIGHT_IGNORE
#define BEBOP_AUTO_EXPOSURE
#define BEBOP_AE_AWB_NICE
#define BEBOP_AE_DARK_IGNORE
#define BEBOP_AWB_MIN_GAINS
#define BEBOP_AWB_MIN_GREY_PIXELS
void bebop_ae_awb_init(void)
struct ae_setting_t ae_set
#define BEBOP_AUTO_WHITE_BALANCE
#define BEBOP_AE_AWB_VERBOSE
#define BEBOP_AWB_GAIN_SCHEDULING_TARGET
#define BEBOP_AE_DARK_BINS
static struct image_t * update_ae_awb(struct image_t *img, uint8_t camera_id)
struct awb_setting_t awb_set
#define BEBOP_AWB_GAIN_SCHEDULING_STEP
#define BEBOP_AWB_GAIN_SCHEDULING_TOLERANCE
#define BEBOP_AE_MIDDLE_INDEX
#define BEBOP_AWB_MAX_GAINS
#define BEBOP_AWB_GAIN_SCHEDULING
#define BEBOP_AE_BRIGHT_BINS
#define BEBOP_AE_EXPOSURE_GAIN
float gain_scheduling_tolerance
float gain_scheduling_target
float gain_scheduling_step
struct video_listener * cv_add_to_device_async(struct video_config_t *device, cv_function func, int nice_level, uint16_t fps, uint8_t id)
Computer vision framework for onboard processing.
uint32_t pprz_ts
The timestamp in us since system startup.
int isp_get_statistics_yuv(struct isp_yuv_stats_t *yuv_stats)
uint32_t awb_nb_grey_pixels
uint32_t ae_histogram_Y[256]
void mt9f002_reset_exposure(struct mt9f002_t *mt)
void mt9f002_set_gains(struct mt9f002_t *mt)
Sets the GreenR, Blue, Red and GreenB gains.
void mt9f002_set_exposure(struct mt9f002_t *mt)
Set the exposure configuration Depends on the blanking (and therefore the FPS)
void mt9f002_reset_color(struct mt9f002_t *mt)
Initialization and configuration of the MT9F002 CMOS Chip.
float target_exposure
Target exposure time in ms.
float gain_red
Gain for the Red pixels [1., 63.50].
float gain_green2
Gain for the GreenB pixels [1., 63.50].
float gain_green1
Gain for the GreenR pixels [1., 63.50].
float gain_blue
Gain for the Blue pixels [1., 63.50].
float real_exposure
Real exposure time in ms.
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
signed char int8_t
Typedef defining 8 bit char type.