📄 af_demo.c
字号:
/* Hardware auto-focus control sys init, execute routines */
#include <stdio.h>
#include <user/af_ctrl.h>
#include <h3a/af_alg_externs.h>
extern AF_CTRL af_ctrl_1, af_ctrl_2;
void AFDemoReset();
void AFDemoRun(Uint16 af_alg_id, Uint16 hstart, Uint16 hend, Uint16 vstart, Uint16 vend, Uint16 ccd_mode);
/*
Needs to be called once during system initialization
*/
void AFDemoInit() {
AFAlg1Init();
AFAlg2Init();
}
/*
Needs to be called to execute the auto-focus algorithm
*/
/*
Uint16 af_id,
0: ALGO - Rule-based , AREA - center vertical 3x4 // NOT SUPPORTED
1: ALGO - Rule-based , AREA - center horizontal 5x2 // NOT SUPPORTED
2: ALGO - Rule-based , AREA - complete area 9x4 // NOT SUPPORTED
3: ALGO - Global-search , AREA - center vertical 3x4
4: ALGO - Global-search , AREA - center horizontal 5x2
5: ALGO - Global-search , AREA - complete area 9x4
Uint16 ccd_mode
0: draft mode
1: af1 mode
Recommended usage,
AFSysExecute(0,0);
*/
void AFDemoExecute(Uint16 af_id, Uint16 ccd_mode) {
Uint16 af_alg_id, hstart, hend, vstart, vend;
if(af_id > 5)
return;
switch(af_id) {
case 0:
af_alg_id =1;
hstart =3;
hend =5;
vstart =0;
vend =3;
break;
case 1:
af_alg_id =1;
hstart =2;
hend =6;
vstart =1;
vend =2;
break;
case 2:
af_alg_id =1;
hstart =0;
hend =8;
vstart =0;
vend =3;
break;
case 3:
af_alg_id =0;
hstart =3;
hend =5;
vstart =0;
vend =3;
break;
case 4:
af_alg_id =0;
hstart =2;
hend =6;
vstart =1;
vend =2;
case 5:
af_alg_id =0;
hstart =0;
hend =8;
vstart =0;
vend =3;
break;
}
AFDemoRun(af_alg_id, hstart, hend, vstart, vend, ccd_mode);
}
/*
Uint16 af_alg_id :: Auto-focus algo, 1:Rule-based, 0:Global-search
Uint16 hstart :: 0..8, hstart <= hend
Uint16 hend :: 0..8
Uint16 vstart :: 0..3, vstart <= vend
Uint16 vend :: 0..3
Uint16 ccd_mode :: 0:draft mode, 1:AF1 mode
Recommended usage,
AFSysExecute( 0, 3, 5, 0, 3, 0); // i.e ALGO - Rule-based , AREA - center vertical 3x4, draft mode
*/
void AFDemoRun(Uint16 af_alg_id, Uint16 hstart, Uint16 hend, Uint16 vstart, Uint16 vend, Uint16 ccd_mode) {
AF_CTRL *af_ctrl=NULL;
AFAlgSetArea(hstart, hend, vstart, vend);
if(af_alg_id==0)
af_ctrl=&af_ctrl_1;
if(af_alg_id==1)
//af_ctrl=&af_ctrl_2; // NOT SUPPORTED
af_ctrl=&af_ctrl_1;
if(af_ctrl!=NULL) {
AFInit( af_ctrl );
AFExecute( af_ctrl );
}
}
/*
Needs to be called atleast once after lens initialization but before first still capture is done
Also needs to be called only if "focus motor position" is changed by a routine other than those called during
Auto-focus execution
*/
void AFDemoReset() {
AFAlgFocusMotorInit();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -