Skip to content

Commit 21c4017

Browse files
committed
Merge branch 'fix/add_ov2710_exp_report' into 'master'
Fix/add ov2710 exp report See merge request espressif/esp-video-components!326
2 parents e69c4af + 11b0887 commit 21c4017

File tree

7 files changed

+70
-5
lines changed

7 files changed

+70
-5
lines changed

esp_cam_sensor/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Added option to return byte swap flags for GC0308
6+
- Added luma para in ov2710 driver.
67

78
## 1.4.0
89

esp_cam_sensor/include/esp_cam_sensor_types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ typedef enum {
7474

7575
#define ESP_CAM_SENSOR_STATS_FLAG_WB_GAIN (1 << 0)
7676
#define ESP_CAM_SENSOR_STATS_FLAG_AGC_GAIN (1 << 1)
77+
#define ESP_CAM_SENSOR_STATS_FLAG_EXPOSURE (1 << 2)
7778

7879
#define ESP_CAM_SENSOR_PARAM_TYPE_NUMBER 1
7980
#define ESP_CAM_SENSOR_PARAM_TYPE_BITMASK 2
@@ -437,7 +438,8 @@ typedef struct {
437438
typedef struct {
438439
uint32_t flags;
439440
uint32_t seq;
440-
uint16_t agc_gain; /*!< AGC gain output to sensor */
441+
uint32_t aec_exp; /*!< AEC exposure output to sensor */
442+
volatile float agc_gain; /*!< AGC gain output to sensor */
441443
union {
442444
struct {
443445
uint8_t red_avg;

esp_cam_sensor/sensors/ov2710/cfg/ov2710_default.json

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,23 @@
101101
1, 1, 1, 1, 1,
102102
1, 1, 1, 1, 1
103103
]
104+
},
105+
"env":
106+
{
107+
"k": 250000,
108+
"speed_param":
109+
[
110+
-0.005463, -0.010018, 0.000000, 0.033241, 0.085583, 0.136704, 0.160734, 0.148777,
111+
0.148777, 0.160734, 0.136704, 0.085583, 0.033241, 0.000000, -0.010018, -0.005463
112+
],
113+
"weight":
114+
[
115+
1, 1, 1, 1, 1,
116+
1, 1, 1, 1, 1,
117+
1, 1, 1, 1, 1,
118+
1, 1, 1, 1, 1,
119+
1, 1, 1, 1, 1
120+
]
104121
}
105122
}
106123
},
@@ -415,7 +432,25 @@
415432
},
416433
"atc":
417434
{
418-
"init_value": 48
435+
"model": 0,
436+
"init_value": 48,
437+
"delay_frames": 3,
438+
"luma_env": "env.luma.avg",
439+
"luma_lut":
440+
[
441+
{
442+
"luma": 250,
443+
"ae_value": 48
444+
},
445+
{
446+
"luma": 500,
447+
"ae_value": 60
448+
},
449+
{
450+
"luma": 750,
451+
"ae_value": 75
452+
}
453+
]
419454
}
420455
}
421456
}

esp_cam_sensor/sensors/ov2710/ov2710.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ static const char *TAG = "ov2710";
5454
static portMUX_TYPE s_stats_mutex = portMUX_INITIALIZER_UNLOCKED;
5555
#endif
5656

57+
#define OV2710_GAIN_V(_v, _b) ((uint32_t)(((_v) >> ((_b))) & 0x01) + 1)
58+
5759
static const esp_cam_sensor_isp_info_t ov2710_isp_info[] = {
5860
/* For MIPI */
5961
{
@@ -62,6 +64,7 @@ static const esp_cam_sensor_isp_info_t ov2710_isp_info[] = {
6264
.pclk = 80000000,
6365
.vts = 1322,
6466
.hts = 2420,
67+
.tline_ns = 30222,
6568
.bayer_type = ESP_CAM_SENSOR_BAYER_BGGR,
6669
}
6770
},
@@ -71,6 +74,7 @@ static const esp_cam_sensor_isp_info_t ov2710_isp_info[] = {
7174
.pclk = 80000000,
7275
.vts = 1322,
7376
.hts = 2420,
77+
.tline_ns = 26666,
7478
.bayer_type = ESP_CAM_SENSOR_BAYER_BGGR,
7579
},
7680
},
@@ -161,7 +165,8 @@ static esp_err_t ov2710_set_reg_bits(esp_sccb_io_handle_t sccb_handle, uint16_t
161165
#if CONFIG_CAMERA_OV2710_STATS_UPDATE_EN
162166
static void wb_timer_callback(TimerHandle_t timer)
163167
{
164-
uint8_t read_v[5] = {0};
168+
uint8_t read_v[8] = {0};
169+
uint8_t read_v2 = 0;
165170
esp_cam_sensor_device_t *dev = (esp_cam_sensor_device_t *)pvTimerGetTimerID(timer);
166171
struct ov2710_cam *cam_ov2710 = (struct ov2710_cam *)dev->priv;
167172

@@ -170,14 +175,28 @@ static void wb_timer_callback(TimerHandle_t timer)
170175
ov2710_read(dev->sccb_handle, OV2710_REG_BLUE_BEFORE_GAIN_AVERAGE, &read_v[2]);
171176
ov2710_read(dev->sccb_handle, OV2710_REG_AEC_AGC_ADJ_MSB, &read_v[3]);
172177
ov2710_read(dev->sccb_handle, OV2710_REG_AEC_AGC_ADJ_LSB, &read_v[4]);
178+
ov2710_read(dev->sccb_handle, OV2710_REG_AEC_EXPO_H, &read_v[5]);
179+
ov2710_read(dev->sccb_handle, OV2710_REG_AEC_EXPO_M, &read_v[6]);
180+
ov2710_read(dev->sccb_handle, OV2710_REG_AEC_EXPO_L, &read_v[7]);
181+
// ov2710_read(dev->sccb_handle, 0x568A, &read_v2);
182+
ov2710_read(dev->sccb_handle, 0x5690, &read_v2);
173183

174184
portENTER_CRITICAL(&s_stats_mutex);
175185
cam_ov2710->ov2710_para.stats.wb_avg.red_avg = read_v[0];
176186
cam_ov2710->ov2710_para.stats.wb_avg.green_avg = read_v[1];
177187
cam_ov2710->ov2710_para.stats.wb_avg.blue_avg = read_v[2];
178-
cam_ov2710->ov2710_para.stats.agc_gain = ((read_v[3] & 0x01) + 1) * ((read_v[4] & 0x80) + 1) * ((read_v[4] & 0x40) + 1) * ((read_v[4] & 0x20) + 1) * ((read_v[4] & 0x10) + 1) * ((read_v[4] & 0x0f) / 16 + 1);
188+
cam_ov2710->ov2710_para.stats.agc_gain = ((float)(read_v[4] & 0xf) / 16.0 + 1.0) * \
189+
OV2710_GAIN_V(read_v[3], 0) * \
190+
OV2710_GAIN_V(read_v[4], 7) * \
191+
OV2710_GAIN_V(read_v[4], 6) * \
192+
OV2710_GAIN_V(read_v[4], 5) * \
193+
OV2710_GAIN_V(read_v[4], 4);
194+
195+
cam_ov2710->ov2710_para.stats.aec_exp = ((uint32_t)(read_v[5] & 0x0f) << 16) | ((uint32_t)read_v[6] << 8) | ((uint32_t)read_v[7]);
179196
cam_ov2710->ov2710_para.stats.seq++;
180197
portEXIT_CRITICAL(&s_stats_mutex);
198+
ESP_LOGD(TAG, "_gain=%f, avg=0x%"PRIx8", _exp=0x%" PRIx32, cam_ov2710->ov2710_para.stats.agc_gain, read_v2, cam_ov2710->ov2710_para.stats.aec_exp);
199+
ESP_LOGD(TAG, "_luma=%f", (float)read_v2 * 1000 / cam_ov2710->ov2710_para.stats.agc_gain / cam_ov2710->ov2710_para.stats.aec_exp);
181200
}
182201
#endif
183202

@@ -626,7 +645,7 @@ esp_cam_sensor_device_t *ov2710_detect(esp_cam_sensor_config_t *config)
626645

627646
#if CONFIG_CAMERA_OV2710_STATS_UPDATE_EN
628647
// Init cam privae pata
629-
cam_ov2710->ov2710_para.stats.flags = ESP_CAM_SENSOR_STATS_FLAG_WB_GAIN | ESP_CAM_SENSOR_STATS_FLAG_AGC_GAIN;
648+
cam_ov2710->ov2710_para.stats.flags = ESP_CAM_SENSOR_STATS_FLAG_WB_GAIN | ESP_CAM_SENSOR_STATS_FLAG_AGC_GAIN | ESP_CAM_SENSOR_STATS_FLAG_EXPOSURE;
630649
cam_ov2710->wb_timer_handle = xTimerCreate("wb_t", CONFIG_CAMERA_OV2710_STATS_UPDATE_INTERVAL / portTICK_PERIOD_MS, pdTRUE,
631650
(void *)dev, wb_timer_callback);
632651
if (!cam_ov2710->wb_timer_handle) {

esp_cam_sensor/sensors/ov2710/private_include/ov2710_regs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ extern "C" {
2525
#define OV2710_REG_BLUE_BEFORE_GAIN_AVERAGE 0x5198 /* R Bit[7:0]: Before AWB gain's blue data average*/
2626
#define OV2710_REG_AEC_AGC_ADJ_MSB 0x350A
2727
#define OV2710_REG_AEC_AGC_ADJ_LSB 0x350B
28+
#define OV2710_REG_AEC_EXPO_H 0x3500
29+
#define OV2710_REG_AEC_EXPO_M 0x3501
30+
#define OV2710_REG_AEC_EXPO_L 0x3502
2831

2932
#ifdef __cplusplus
3033
}

esp_video/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Add RISC-V software swap byte function for DVP video device
44
- Add the customized video class to call esp_cam_sensor ioctl commands directly
55
- Add the second SPI video device
6+
- Add camera sensor exposure parameter to statistics
67
- Improve AEC controller time precision
78
- Fix the CSI video device initializes twice when starting up
89
- Update to use esp_cam_sensor v1.4.x

esp_video/src/esp_video_isp_pipeline.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,10 @@ static void get_sensor_state(esp_video_isp_t *isp, int index)
906906
isp->sensor.cur_gain = sensor_stats.agc_gain;
907907
}
908908

909+
if (sensor_stats.flags & ESP_CAM_SENSOR_STATS_FLAG_EXPOSURE) {
910+
isp->sensor.cur_exposure = sensor_stats.aec_exp;
911+
}
912+
909913
if (sensor_stats.flags & ESP_CAM_SENSOR_STATS_FLAG_WB_GAIN) {
910914
isp_awb_stat_result_t *awb = &isp->isp_stats[index]->awb.awb_result;
911915

0 commit comments

Comments
 (0)