【AT-START-F403A测评】之 4、二维码扫描测试
本帖最后由 lmyyz 于 2020-10-12 16:19 编辑<p> 我们先看一下原厂给的演示例程,main主函数:</p>
<pre>
<code>int main(void)
{
static u8 bartype=0;
u8 result={0} ;
u8 result_compare={0} ;
u8 Play_times = 0 ;
AT32_Board_Init();
NVIC_Configuration();
UART_Print_Init(115200);
KEY_And_LED_Crl_Init();
EXTIX_Init();
//sensor clock
Clock_Output_Config();//24Mhz
LCD_SPI1_Init();
LCD_Init();
LCD_display_initial_info();
//camera spi
BF3901_SPI_Init();
BF3901_SCCB_Init();
SCCB_WR_Reg(0x12,0x80);
while(BF3901_Init())//3?ê??ˉBF3901
{
LCD_ShowString(5,70,200,16,16,"BF3901 Error!!");
Delay_ms(200);
}
LCD_ShowString(5,70,200,16,16,"BF3901 Init OK");
printf("1SRAM IN:%d\r\n",my_mem_perused(SRAMIN));
Artery_QR_init();
printf("2SRAM IN:%d\r\n",my_mem_perused(SRAMIN));
LCD_ShowString(5,120,200,20,16,"Please push the USER key to test QR decode!!");
//USB configure
AT32_USB_GPIO_init(); //USB GPIO configure
Delay_ms(500);
USB_Interrupts_Config(); //Enable USB Interrut
Set_USBClock(0); //Set USB Clock, USB Clock must 48MHz
USB_Init(); //USB protocol and register initialize
while(Key_run != 0x55); //
Key_run = 0x22;
DMA_SPIx_Enable();
Delay_ms(500);
LCD_Clear(WHITE);
BlockWrite((lcddev.width-LCD_WIDTH)/2,(lcddev.width+LCD_WIDTH)/2-1,(lcddev.height-LCD_HEIGHT)/2,(lcddev.height+LCD_HEIGHT)/2-1); // 240*320
EXTI14_Init();
while(1)
{
camera_refresh();//
//run ATK_QR
while(Get_Frame == 1)
{
Artery_QR__decode(240,240,bmp,bartype,result);
if(result==0)
{
#if defined(Only_detect_QR)
printf("Not detect !");
bartype=0;
Get_Frame = 0;
#elif defined(Detect_all)
bartype++;?
if(bartype>=5)
{
printf("Not detect !");
bartype=0;
Get_Frame = 0;
}
#endif
if(Key_run == 0x55)
{
LCD_Clear(WHITE);
BlockWrite((lcddev.width-LCD_WIDTH)/2,(lcddev.width+LCD_WIDTH)/2-1,(lcddev.height-LCD_HEIGHT)/2,(lcddev.height+LCD_HEIGHT)/2-1); // 240*320
Delay_sec(2);
Key_run = 0x22;
}
}
else if(result!=0)//ê?±e3?à′á?£???ê??á1?
{
//?ì·??ù?÷
GPIO_SetBits(GPIOE, GPIO_Pins_15);
Delay_ms(600);Delay_ms(600);
GPIO_ResetBits(GPIOE, GPIO_Pins_15);
if(Buffercmp(result_compare,result,sizeof(result)) == 1)
{
Play_times++;
}else{
Play_times=1;
}
// Dispaly data to LCD
LCD_Clear(WHITE);
LCD_ShowString(5,10,200,16,16,"The times:");
LCD_ShowNum(130,10,Play_times,2,16);
LCD_ShowString(5,30,200,16,16,"The result :");
LCD_ShowString(5,50,200,100,16,result);
LCD_ShowString(5,190,200,20,16,"Please push the USER key to test QR decode!!");
printf("\r\nresult:\r\n%s\r\n",result);
// Transmit data to USB
usb_printf("The times:%d\r\n",Play_times);
usb_printf("The result :\r\n");
recvLen = strlen((const char*)result);
sendLen = CDC_Send_DATA(result, recvLen);
usb_printf("\r\n\r\n");
AT32_LEDn_Toggle(LED3);
memcpy(result_compare,result,sizeof(result));
Key_run = 0x66;
if(Key_run != 0x66)
{
Delay_sec(3);
LCD_Clear(WHITE);
BlockWrite((lcddev.width-LCD_WIDTH)/2,(lcddev.width+LCD_WIDTH)/2-1,(lcddev.height-LCD_HEIGHT)/2,(lcddev.height+LCD_HEIGHT)/2-1); // 240*320
}
Get_Frame = 0;
}
}
if(Key_run == 0x11)
{
Get_Frame = 0;
Line_Refresh_Flg = RX_IDLE_FLG;
Delay_sec(3);
LCD_Clear(WHITE);
BlockWrite((lcddev.width-LCD_WIDTH)/2,(lcddev.width+LCD_WIDTH)/2-1,(lcddev.height-LCD_HEIGHT)/2,(lcddev.height+LCD_HEIGHT)/2-1); // 240*320
Delay_sec(2);
Key_run = 0x22;
}
}
}</code></pre>
<p> 总结一下:显示初始化IO口,lcd接口,摄像头BF3901接口,(吐槽一下,把摄像头换成OV的难道不香么,到现在BF3901的PDF资料我都没找到<img height="53" src="https://bbs.eeworld.com.cn/static/editor/plugins/hkemoji/sticker/facebook/sad.gif" width="54" />)。</p>
<p> 初始化结束后按一下按键正式进入二维码扫描功能。流程如下:摄像头一直扫描图像,一边扫描一遍显示在lcd屏上,扫描完一帧(这里设置的是240*240像素)后开始处理图像信息,通过二维码识别.lib返回最终的结果,不成功的话继续扫描。接下来我们一起看看二维码识别的效果怎么样!</p>
<p>=================================================</p>
<p> 华丽的分割线</p>
<p>=================================================</p>
<p> 让我们来看一下扫描效果:果然扫描成功了!</p>
<p> 为了模拟实际使用情况,我稍微将程序修改了一下,摄像头一直扫描图像,图像识别我改为按键控制了,按下按键后识别图像,看一下效果吧:。</p>
<p> 好了,二维码扫描验证至此结束,接下来我将把摄像头改成OV的,对比一下效果看看咯。</p>
<p>ov的好像没有spi接口的,其实我想知道的是这个spi接口的摄像头,单纯采集帧率多大</p> <p><a href="https://bbs.eeworld.com.cn/thread-1143018-1-1.html" target="_blank">雅特力AT-START-F403A测评汇总</a></p>
<p>汇总贴:<a href="https://bbs.eeworld.com.cn/thread-1143018-1-1.html" target="_blank">https://bbs.eeworld.com.cn/thread-1143018-1-1.html</a></p>
<p><a href="https://bbs.eeworld.com.cn/thread-1143018-1-1.html" target="_blank">雅特力AT-START-F403A测评汇总</a></p>
<p>汇总贴:<a href="https://bbs.eeworld.com.cn/thread-1143018-1-1.html" target="_blank">https://bbs.eeworld.com.cn/thread-1143018-1-1.html</a></p>
页:
[1]