图像更改
This commit is contained in:
39
app/main.c
39
app/main.c
@@ -23,14 +23,11 @@
|
||||
********************************************************************************************************************/
|
||||
#include "gl_headfile.h"
|
||||
#include "by_rt_button.h"
|
||||
#include "by_fan_control.h"
|
||||
#include "./page/page.h"
|
||||
#include "jj_blueteeth.h"
|
||||
#include "jj_param.h"
|
||||
#include "./page/page_ui_widget.h"
|
||||
#include "by_buzzer.h"
|
||||
#include "jj_motion.h"
|
||||
#include "by_imu.h"
|
||||
int main(void)
|
||||
{
|
||||
|
||||
@@ -41,29 +38,19 @@ int main(void)
|
||||
ips200_init(IPS200_TYPE_SPI);
|
||||
by_gpio_init();
|
||||
by_exit_init();
|
||||
by_pwm_init();
|
||||
jj_bt_init();
|
||||
by_buzzer_init();
|
||||
while (imu660ra_init())
|
||||
;
|
||||
jj_param_eeprom_init();
|
||||
Page_Init();
|
||||
sport_pid_init();
|
||||
pit_ms_init(TIM6_PIT, 2);
|
||||
pit_ms_init(TIM1_PIT, 2);
|
||||
// gyroOffset_init();
|
||||
|
||||
while (1) {
|
||||
Page_Run();
|
||||
jj_bt_run();
|
||||
queue_pop_read();
|
||||
bt_printf("hello:%f,%f\n",out_M,out_yaw);
|
||||
if (mt9v03x_finish_flag) {
|
||||
// 该操作消耗大概 1970 个 tick,折合约 110us
|
||||
memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
|
||||
//adaptiveThreshold((uint8_t*)mt9v03x_image_copy, (uint8_t*)mt9v03x_image_copy, 188, 120, 7, 17);
|
||||
//ips200_show_gray_image(0, 0, mt9v03x_image_copy[0], MT9V03X_W, MT9V03X_H, MT9V03X_W, MT9V03X_H, 0);
|
||||
mt9v03x_finish_flag = 0;
|
||||
|
||||
state_type = COMMON_STATE;
|
||||
img_processing();
|
||||
get_corners();
|
||||
@@ -72,27 +59,13 @@ int main(void)
|
||||
ElementJudge();
|
||||
ElementRun();
|
||||
MidLineTrack();
|
||||
|
||||
ips200_show_float(0,180,pure_angle,2,2);
|
||||
ips200_show_int(0, 200, track_type, 2);
|
||||
ips200_show_int(0, 220, garage_type, 2);
|
||||
ips200_show_int(0, 240, cross_type, 2);
|
||||
ips200_show_int(0, 260, circle_type, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void adaptiveThreshold(uint8_t* img_data, uint8_t* output_data, int width, int height, int block, uint8_t clip_value){
|
||||
int half_block = block / 2;
|
||||
for(int y=half_block; y<height-half_block; y++){
|
||||
for(int x=half_block; x<width-half_block; x++){
|
||||
// 计算局部阈值
|
||||
int thres = 0;
|
||||
for(int dy=-half_block; dy<=half_block; dy++){
|
||||
for(int dx=-half_block; dx<=half_block; dx++){
|
||||
thres += img_data[(x+dx)+(y+dy)*width];
|
||||
}
|
||||
}
|
||||
thres = thres / (block * block) - clip_value;
|
||||
// 进行二值化
|
||||
output_data[x+y*width] = img_data[x+y*width]>thres ? 255 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user