找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5016|回复: 6
打印 上一主题 下一主题
收起左侧

STM32 Camera二维码识别源码

[复制链接]
跳转到指定楼层
楼主
ID:255911 发表于 2017-11-30 22:06 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
可以进来看看?下面有我自己的例程下载。

单片机源程序如下:
  1. /**
  2.   * @file    main.c
  3.   * @author  WB R&D Team - openmcu666
  4.   * @version V0.1
  5.   * @date    2016.08.24
  6.   * @brief   Main Program body
  7.   */

  8. #include "stm32f4xx.h"
  9. #include "Gpio.h"
  10. #include "usart.h"
  11. #include "delay.h"
  12. #include "stm32f429i_lcd.h"
  13. #include "ov7670.h"
  14. #include "ov2640.h"
  15. #include "ov5642.h"
  16. #include "mt9d111.h"
  17. #include "CamConfig.h"
  18. #include "sccb_bus.h"
  19. #include "RTC.h"
  20. #include "string.h"
  21. #include "QR_Decoder.h"

  22. //only for OV5642

  23. /*****************************************************************************
  24. **   Main Function  main()
  25. ******************************************************************************/
  26. int main(void)
  27. {
  28.         uint16_t temper;
  29.         char  qr_type_len=0;
  30.   short qr_data_len=0;
  31.   char qr_type_buf[10];
  32.   char qr_data_buf[512];
  33.   int addr=0;
  34.   int i=0,j=0;
  35.   char qr_num=0;
  36.        
  37.        
  38.         USART1_Init();
  39.         //LED_Init();
  40.   Key_Init();
  41.         BEEP_Init();
  42.         printf("\r\n");
  43.         printf("Hello Welcome.\r\n");
  44.         printf("Thank You For Choosing Our Products.\r\n");
  45.         printf("Thank You Very Much.\r\n");
  46.         printf("This Example Camera.\r\n");
  47.         printf("\r\n");
  48.         printf("DCMI Initialization...\r\n");
  49.         LCD_Init();
  50.         LCD_LayerInit();
  51.   LTDC_Cmd(ENABLE);
  52.   LCD_SetLayer(LCD_BACKGROUND_LAYER);  
  53.         LCD_SetTransparency(0xFF);
  54.         LCD_Clear(BLACK);
  55.         LCD_SetLayer(LCD_FOREGROUND_LAYER); //使用前景层
  56.   LCD_SetTransparency(0xFF);          //设置透明度
  57.   LCD_Clear_ARGB8888(0x40000000);
  58.    
  59.   LCD_SetTextColor_ARGB8888(0xFFFFFFFF);
  60.   LCD_DrawFullRect_ARGB8888(Frame_Width,Frame_Width);                              //绘制透明框
  61.   
  62.   LCD_DrawBox_ARGB8888(Frame_Width,Frame_Line_Length,Frame_Line_Size,0xD05CBDE7);  //绘制扫描框
  63.        
  64.         printf("Ok,Let's Go...\r\n");
  65.        
  66.         temper = ov7670_check();         //Camera是否为OV7670
  67.          
  68.         if (temper == 0x7673)
  69.         {
  70.                 printf("Cam ID : [0x%02x]\r\n",temper);
  71.                 if (ov7670_init())
  72.                 {
  73.                         printf("Init OV7670 reg Fail...\r\n");
  74.                   while (1)
  75.                   {
  76.                                
  77.                   }
  78.                 }
  79.                 else
  80.                 {
  81.                         printf("Init OV7670 reg OK...\r\n");
  82.                         printf("Show Camer Data...\r\n");

  83.                 }               
  84.                
  85.         }
  86.         else                                       
  87.         {
  88.     temper=ov2640_check();
  89.           
  90.                 if(temper==0x2642)                        //OV2640
  91.                 {
  92.                         if (ov2640_init())
  93.                   {
  94.                         printf("Init OV2640 reg Fail...\r\n");
  95.                         while (1)
  96.                         {}
  97.                   }
  98.                   else
  99.                  {
  100.                         printf("Cam ID : [0x%02x]\r\n",temper);
  101.                         printf("Init OV2640 reg OK...\r\n");
  102.                         printf("Show Camer Data...\r\n");

  103.                  }
  104.         
  105.          }
  106.                 else                                        //ov5642 or mt9d111
  107.     {
  108.                         temper=ov5642_check();
  109.                         printf("Cam ID : [0x%02x]\r\n",temper);
  110.                   if (temper==0x5642)//mt9d111_init
  111.                   {
  112.                           ov5642_init();
  113.                           printf("Init ov5642 reg OK...\r\n");
  114.                           printf("Show Camer Data...\r\n");       
  115.                   }
  116.                  else
  117.                  {
  118.                           printf("Init ov5642 reg Fail...\r\n");                               
  119.                                 while (1){}
  120.                  }
  121.     }
  122.         }
  123. //        if(RTC_Config())                                                           //初始化RTC
  124. //        {
  125. //          printf("\r\nLSE start failed\r\n");
  126. //        }
  127. //        RTC_Set_WakeUp(RTC_WakeUpClock_CK_SPRE_16bits,0);                //配置WAKE UP中断,1秒钟中断一次,用于统计帧率
  128.   systick_delay_ms(100);
  129.         ov5642_auto_focus();
  130.         cam_start();
  131.        
  132.         while (1)
  133.   {
  134.     qr_num = QR_decoder();
  135.                  if(qr_num)
  136.       {
  137.          GPIO_SetBits(BEEP_GPIO_PORT,BEEP_GPIO_PIN);
  138.                                  systick_delay_ms(100);
  139.                                  GPIO_ResetBits(BEEP_GPIO_PORT,BEEP_GPIO_PIN);
  140.          //解码的数据是按照识别条码的个数封装好的二维数组,这些数据需要
  141.          //根据识别条码的个数,按组解包并通过串口发送到上位机串口终端
  142.          for(i=0;i < qr_num;i++)
  143.          {
  144.            qr_type_len = decoded_buf[i][addr++];//获取解码类型长度
  145.                
  146. ……………………

  147. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
【02】红龙429_Camera二维码识别().rar (1.15 MB, 下载次数: 62)


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏3 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:113953 发表于 2017-12-5 11:12 | 只看该作者
这可是旺宝电子的代码。你是旺宝电子的?
回复

使用道具 举报

板凳
ID:300493 发表于 2018-4-1 19:29 | 只看该作者
可不可以用到51单片机里
回复

使用道具 举报

地板
ID:300858 发表于 2018-4-2 14:50 | 只看该作者
非常感谢 支持啊 多谢楼主
回复

使用道具 举报

5#
ID:166329 发表于 2018-8-18 00:25 | 只看该作者
好东西下载学习下
回复

使用道具 举报

6#
ID:166329 发表于 2018-8-18 00:25 | 只看该作者
不错,学习了
回复

使用道具 举报

7#
ID:488243 发表于 2019-7-23 11:01 | 只看该作者
很好,正好可以学习如何用STM32 来实现二维码扫描,谢谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表