修改自动曝光
This commit is contained in:
@ -21,13 +21,14 @@ void Send_Shutter_Time(uint32_t shutter_time) {
|
||||
HAL_UART_Transmit(&huart2,t_buff,4,100);
|
||||
}
|
||||
|
||||
|
||||
uint32_t Opt_Snenser(int persent, uint16_t *data,uint32_t Size,uint32_t Shutter_Now) {
|
||||
//自动曝光 成功返回曝光时间 失败返回0
|
||||
uint32_t Opt_Snenser(int persent, uint16_t *data,uint32_t Size) {
|
||||
int maxvalue=maxValue*1.0*persent / 100;
|
||||
int maxvaluenow = 0;
|
||||
uint32_t shutter_time;
|
||||
uint32_t max_shutter_time = 100;
|
||||
|
||||
uint32_t min_shutter_time = 10;
|
||||
static uint32_t shutter_time;
|
||||
shutter_time < min_shutter_time ? shutter_time = min_shutter_time : shutter_time;
|
||||
|
||||
for (int i = 0; i < Size; i++) {
|
||||
if (data[i] > maxvaluenow) {
|
||||
@ -35,15 +36,15 @@ uint32_t Opt_Snenser(int persent, uint16_t *data,uint32_t Size,uint32_t Shutter
|
||||
}
|
||||
}
|
||||
|
||||
if (Shutter_Now<=min_shutter_time || Shutter_Now>=max_shutter_time) return 0;
|
||||
if (maxvaluenow<maxvalue || maxvaluenow >= maxvalue*1.05 ) {
|
||||
shutter_time = shutter_time * maxvalue / maxvaluenow;
|
||||
|
||||
shutter_time < min_shutter_time ? shutter_time = min_shutter_time : shutter_time;
|
||||
|
||||
if (maxvaluenow<maxvalue*0.95 || maxvaluenow>maxvalue) {
|
||||
shutter_time = Shutter_Now * maxvaluenow / maxvalue;
|
||||
Send_Shutter_Time(shutter_time);
|
||||
|
||||
HAL_Delay(1000);
|
||||
return shutter_time;
|
||||
if (shutter_time <= min_shutter_time ) return shutter_time;
|
||||
}
|
||||
else return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user