包含圖像二值化
單片機(jī)源程序如下:
- /*!
- * COPYRIGHT NOTICE
- * Copyright (c) 2013,山外科技
- *
- * 除注明出處外,以下所有內(nèi)容版權(quán)均屬山外科技所有,未經(jīng)允許,不得用于商業(yè)用途,
- * 修改內(nèi)容時必須保留山外科技的版權(quán)聲明。
- *
- * @file main.c
- * @brief 山外K60 UD版平臺主程序
- * @author 山外科技
- * @version v6.0
- * @date 2016-09-25
- */
- #include "include.h"
- #include "motor.h"
- #include "camera.h"
- #include "servo.h"
- #include "image_process.h"
- #include "menu.h"
- #include "flash.h"
- #include "ultrasonic.h"
- #include "switch.h"
- #include "bluetooth.h"
- #include "isr.h"
- uint8 cnt;
- #if defined CAR_1
- #define VSYNC_ PTD17
- #define HREF_ PTD16
- #define PCLK_ PTD18
- #endif
- /*
- #if defined CAR_2
- #define VSYNC_ PTC17 //PTD14
- #define HREF_ PTC16 //PTD13
- #define PCLK_ PTC18 //PTD12
- #endif
- */
- volatile Image gImage;//(60,10)
- //! 初始化攝像頭
- inline static void CameraInit()
- {
- IICWriteGpio_inintOV();//初始化設(shè)置SCCB引腳
- while (ov7725_probe() == 0)//初始化寄存器
- ;
- ov7725_set_image_size(IMAGE_SIZE);//設(shè)置圖像大小
- CameraSetImageBuffer(gImage);
- CameraInterruptInit();//中斷初始化
- }
- //! 撥碼開關(guān)的值
- volatile float switch_val = 0;
- typedef void (*func_t)(void);
- volatile
- float k, b;
- float SpeedDiffCoeff2(float servoduty)
- {
- return k / 1000 * fabsf(servoduty) + b;
- }
- void PortEHandler(void)
- {
- PORT_FUNC(E, 27, nrf_handler);
- }
- void main()
- {
- SwitchInit();
- switch_val = GetSwitchValue();
-
- led_init(LED0);
- led_init(LED1);
- led_init(LED2);
- led_init(LED3);
- // switch ((int)switch_val)
- // {
- // case 0:
- // break;
- // case 1:
- // ((func_t)(80 * 0x400 + 0x411))();
- // break;
- // case 2:
- // ((func_t)(150 * 0x400 + 0x411))();
- // break;
- // default:
- // break;
- // }
-
- // while(!nrf_init()) //初始化NRF24L01+ ,等待初始化成功為止
- // {
- // led(LED0, LED_ON);
- // }
- led(LED0, LED_OFF);
- set_vector_handler(PORTE_VECTORn, PortEHandler);
- NVIC_EnableIRQ(PORTE_IRQn);
- led(LED0, LED_OFF);
- led(LED1, LED_OFF);
- led(LED2, LED_OFF);
- led(LED3, LED_OFF);
- //LoadFlashData(switch_val);
- SpeedCountInit();//編碼器速度
- OLED_Init();
- CameraInit();
- ServoInit();
- MotorInit();
- MenuInterruptInit();
-
- // BluetoothInit();
- enable_irq(DMA4_IRQn);
-
- CameraGetImage(gImage);
-
- for (;;)
- {
- CameraWait();
- ExtractArray(imgbuff, (uint8_t const (*)[10])gImage);//得到bool型(60,80)型數(shù)組imgbuff
- CameraGetImage(gImage);
- ImageProcess(imgbuff);//圖像處理
-
- //SpeedControl();
- //if(cnt==0)
- // roundabout0();
- //if(cnt==1)
- // roundabout1();
- //if(cnt==2)
- //roundabout2();
-
- ServoControl();
- motor_run();
- if (gMenuQueryImage)//菜單oled??
- {
- memcpy(gOledImageBuffer, gImage, DATALINE * DATACOUNT);
- gMenuQueryImage = 0;
- }
-
-
- #if 1
- //BluetoothSend();
- #else
- /* pid debugging code */
- int16_t iSpeedL = speed_l;
- int16_t iSpeedR = speed_r;
-
- uart_putchar(UART0, 0x03);
- uart_putchar(UART0, 0xFC);
- uart_putbuff(UART0, (void *)&iSpeedL, sizeof iSpeedL);
- uart_putbuff(UART0, (void *)&iSpeedR, sizeof iSpeedR);
- uart_putchar(UART0, 0xFC);
- uart_putchar(UART0, 0x03);
- #endif
- }
- }
復(fù)制代碼
所有資料51hei提供下載:
可跑1.1.7z
(1013.65 KB, 下載次數(shù): 65)
2018-12-15 17:23 上傳
點(diǎn)擊文件名下載附件
攝像頭識別 下載積分: 黑幣 -5
|