能够实现将ov7725的图像上传到上位机,上位机使用原子带的就行,速度比较慢
单片机源程序如下:
- #include "stm32f10x.h"
- #include "./ov7725/ov7725.h"
- #include "./lcd/ili9341_lcd.h"
- #include "./usart/usart.h"
- #include "./systick/SysTick.h"
- extern uint8_t Ov7725_vsync;
- uint64_t Task_Delay = 20000;
- extern OV7725_MODE_PARAM cam_mode;
- int main(void)
- {
-
- // float frame_count = 0;
- uint8_t retry = 0;
- // uint16_t x,y;
- /* 液晶初始化 */
- // ILI9341_Init();
- // ILI9341_GramScan ( 3 );
-
- // LCD_SetFont(&Font8x16);
- // LCD_SetColors(WHITE,BLACK);
- // ILI9341_Clear(0,0,LCD_X_LENGTH,LCD_Y_LENGTH); /* 清屏,显示全黑 */
-
- /********显示字符串示例*******/
- // ILI9341_DispStringLine_EN(LINE(0),"BH OV7725 Test Demo");
- USART_Config();
- SysTick_Init();
- /* ov7725 gpio 初始化 */
- OV7725_GPIO_Config();
-
- /* ov7725 寄存器默认配置初始化 */
- while(OV7725_Init() != SUCCESS)
- {
- retry++;
- if(retry>5)
- {
- // printf("\r\n没有检测到OV7725摄像头\r\n");
- // ILI9341_DispStringLine_EN(LINE(2),"No OV7725 module detected!");
- while(1);
- }
- }
- /*根据摄像头参数组配置模式*/
- OV7725_Special_Effect(cam_mode.effect);
- /*光照模式*/
- OV7725_Light_Mode(cam_mode.light_mode);
- /*饱和度*/
- OV7725_Color_Saturation(cam_mode.saturation);
- /*光照度*/
- OV7725_Brightness(cam_mode.brightness);
- /*对比度*/
- OV7725_Contrast(cam_mode.contrast);
- /*特殊效果*/
- OV7725_Special_Effect(cam_mode.effect);
-
- /*设置图像采样及模式大小*/
- OV7725_Window_Set(cam_mode.cam_sx,
- cam_mode.cam_sy,
- cam_mode.cam_width,
- cam_mode.cam_height,
- cam_mode.QVGA_VGA);
- /* 设置液晶扫描模式 */
- // ILI9341_GramScan( cam_mode.lcd_scan );
-
-
-
- // ILI9341_DispStringLine_EN(LINE(2),"OV7725 initialize success!");
-
- Ov7725_vsync = 0;
-
- while(1)
- {
- /*接收到新图像进行显示*/
- if( Ov7725_vsync == 2 )
- {
- // frame_count++;
- FIFO_PREPARE; /*FIFO准备*/
- /*60秒采集一帧图像通过串口1发送出去*/
- if(Task_Delay == 0)
- {
- while(SUCCESS != ImagCatch(cam_mode.lcd_sx,
- cam_mode.lcd_sy,
- cam_mode.cam_width,
- cam_mode.cam_height)); /*采集并显示,等待串口1图像数据发送完成,*/
- Task_Delay = 60000;
- }
- Ov7725_vsync = 0;
- }
- }
- }
- /*每隔一段时间计算一次帧率*/
- // if(Task_Delay == 0)
- // {
- // printf("\r\nframe_ate = %.2f fps\r\n",frame_count/10); //计算帧率
- // frame_count = 0; //帧数清零
- // Task_Delay = 10000; //10秒定时中断
- // }
复制代码
所有资料51hei提供下载:
基于OV7725的stm32实时图像采集工程.7z
(210.91 KB, 下载次数: 115)
|