测试图像代码
This commit is contained in:
10
.vscode/launch.json
vendored
10
.vscode/launch.json
vendored
@@ -5,13 +5,13 @@
|
||||
"cwd": "${workspaceRoot}",
|
||||
"type": "cortex-debug",
|
||||
"request": "launch",
|
||||
"name": "jlink",
|
||||
"servertype": "jlink",
|
||||
"interface": "swd",
|
||||
"name": "openocd",
|
||||
"servertype": "openocd",
|
||||
"executable": "build\\Debug\\violet_firmware_zf.elf",
|
||||
"runToEntryPoint": "main",
|
||||
"device": "null",
|
||||
"toolchainPrefix": "riscv-none-embed"
|
||||
"configFiles": [
|
||||
"${workspaceFolder}/tools/wch-riscv.cfg"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
#define IMAGE_H (MT9V03X_H)
|
||||
#define IMAGE_W (MT9V03X_W)
|
||||
#define BEGINH_L (61)
|
||||
#define BEGINH_R (61)
|
||||
#define BEGINH_L (80)
|
||||
#define BEGINH_R (80)
|
||||
#define BEGINW_L (-18)
|
||||
#define BEGINW_R (-12)
|
||||
#define PT_MAXLEN (75)
|
||||
|
||||
73
app/main.c
73
app/main.c
@@ -89,23 +89,29 @@ int frame_count = 0;
|
||||
|
||||
void img_processing();
|
||||
void get_corners();
|
||||
void adaptiveThreshold(uint8_t* img_data, uint8_t* output_data, int width, int height, int block, uint8_t clip_value);
|
||||
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
clock_init(SYSTEM_CLOCK_120M); // <20><>ʼ<EFBFBD><CABC>оƬʱ<C6AC><CAB1> <20><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>Ϊ 120MHz
|
||||
debug_init(); // <20><><EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC> MPU ʱ<><CAB1> <20><><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>
|
||||
// mt9v03x_init();
|
||||
//mt9v03x_init();
|
||||
// system_delay_ms(2000);
|
||||
ips200_init(IPS200_TYPE_SPI);
|
||||
by_gpio_init();
|
||||
by_exit_init();
|
||||
by_pwm_init();
|
||||
cw_servo_init();
|
||||
while (imu660ra_init())
|
||||
;
|
||||
mt9v03x_init();
|
||||
// by_gpio_init();
|
||||
// by_exit_init();
|
||||
// by_pwm_init();
|
||||
// cw_servo_init();
|
||||
//printf("hello world\n");
|
||||
// while (imu660ra_init())
|
||||
// ;
|
||||
|
||||
system_delay_ms(2000);
|
||||
gyroOffset_init();
|
||||
pit_ms_init(TIM6_PIT, 2);
|
||||
// system_delay_ms(2000);
|
||||
// gyroOffset_init();
|
||||
// pit_ms_init(TIM6_PIT, 2);
|
||||
|
||||
while (1) {
|
||||
// while (frame_count < 20) {
|
||||
@@ -113,36 +119,57 @@ int main(void)
|
||||
// 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, 8);
|
||||
// //threshold((uint8_t*)mt9v03x_image_copy, (uint8_t*)mt9v03x_image_copy, MT9V03X_W, MT9V03X_H, 110);
|
||||
// ips114_show_gray_image(0, 0, mt9v03x_image_copy[0], MT9V03X_W, MT9V03X_H, MT9V03X_W, MT9V03X_H, 0);
|
||||
// ips200_show_gray_image(0, 0, mt9v03x_image_copy[0], MT9V03X_W, MT9V03X_H, MT9V03X_W, MT9V03X_H, 0);
|
||||
// mt9v03x_finish_flag = 0;
|
||||
// frame_count++;
|
||||
// }
|
||||
|
||||
//}
|
||||
if (mt9v03x_finish_flag) {
|
||||
// ips114_show_gray_image(0, 0, mt9v03x_image[0], 188, 120, 188, 120,0);
|
||||
memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
|
||||
// Img_Gray = mt9v03x_image;
|
||||
// mt9v03x_image_copy[0] = Img_Gray[0];
|
||||
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();
|
||||
//get_corners();
|
||||
|
||||
aim_distance = COMMON_AIM;
|
||||
//aim_distance = COMMON_AIM;
|
||||
|
||||
tracking();
|
||||
//tracking();
|
||||
//printf("1\r\n");
|
||||
//system_delay_ms(100);
|
||||
|
||||
ElementJudge();
|
||||
//ElementJudge();
|
||||
|
||||
ElementRun();
|
||||
//ElementRun();
|
||||
|
||||
MidLineTrack();
|
||||
//MidLineTrack();
|
||||
}
|
||||
// // by_imu_data_get();
|
||||
// // by_ips_show();
|
||||
// // system_delay_ms(200);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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++){
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>ֵ
|
||||
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;
|
||||
// <20><><EFBFBD>ж<EFBFBD>ֵ<EFBFBD><D6B5>
|
||||
output_data[x+y*width] = img_data[x+y*width]>thres ? 255 : 0;
|
||||
}
|
||||
// by_imu_data_get();
|
||||
by_ips_show();
|
||||
system_delay_ms(200);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user