2023-12-17 16:11:35 +08:00
|
|
|
|
#include "zf_common_headfile.h"
|
|
|
|
|
|
#include "math.h"
|
|
|
|
|
|
#include "gl_headfile.h"
|
|
|
|
|
|
|
|
|
|
|
|
enum garage_type_e garage_type = GARAGE_NONE;
|
|
|
|
|
|
|
|
|
|
|
|
float (*garage_rpts)[2];
|
|
|
|
|
|
int garage_rpts_num;
|
|
|
|
|
|
|
2024-03-10 19:47:21 +08:00
|
|
|
|
float calculate_vector_angle(float x1, float y1, float x2, float y2)
|
|
|
|
|
|
{
|
2023-12-17 16:11:35 +08:00
|
|
|
|
float dx = x2 - x1;
|
|
|
|
|
|
float dy = y2 - y1;
|
|
|
|
|
|
|
2024-03-10 19:47:21 +08:00
|
|
|
|
float vector_length = sqrt(dx * dx + dy * dy);
|
2023-12-17 16:11:35 +08:00
|
|
|
|
float angle_radians = acos(dx / vector_length);
|
|
|
|
|
|
float angle_degrees = angle_radians * 180 / M_PI;
|
|
|
|
|
|
|
|
|
|
|
|
return angle_degrees;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-10 19:47:21 +08:00
|
|
|
|
void CheckGarage()
|
|
|
|
|
|
{
|
|
|
|
|
|
int change_num = 0;
|
2024-01-13 18:20:39 +08:00
|
|
|
|
int check_garage_h = 60;
|
2024-03-10 19:47:21 +08:00
|
|
|
|
for (int check_garage_w = 50; check_garage_w < IMAGE_W - 50; check_garage_w++) {
|
2024-01-13 18:20:39 +08:00
|
|
|
|
if ((GET_PIX_1C(mt9v03x_image_copy[0], check_garage_h, check_garage_w) < FIX_BINTHRESHOLD && GET_PIX_1C(mt9v03x_image_copy[0], check_garage_h, check_garage_w + 1) >= FIX_BINTHRESHOLD) ||
|
2024-03-10 19:47:21 +08:00
|
|
|
|
(GET_PIX_1C(mt9v03x_image_copy[0], check_garage_h, check_garage_w) >= FIX_BINTHRESHOLD && GET_PIX_1C(mt9v03x_image_copy[0], check_garage_h, check_garage_w + 1) < FIX_BINTHRESHOLD)) {
|
2024-01-13 18:20:39 +08:00
|
|
|
|
change_num++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-12-17 16:11:35 +08:00
|
|
|
|
|
2024-03-10 19:47:21 +08:00
|
|
|
|
if (change_num > 14) {
|
2024-01-13 18:20:39 +08:00
|
|
|
|
garage_type = GARAGE_FOUND;
|
2024-03-10 19:47:21 +08:00
|
|
|
|
// printf("跳变点的数量为:%d\r\n", change_num);
|
2024-01-13 18:20:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-10 19:47:21 +08:00
|
|
|
|
change_num = 0;
|
2024-01-13 18:20:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-10 19:47:21 +08:00
|
|
|
|
void RunGarage()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (garage_type == GARAGE_FOUND) {
|
2024-01-13 18:20:39 +08:00
|
|
|
|
printf("识别到车库\r\n");
|
2024-03-10 19:47:21 +08:00
|
|
|
|
garage_type = GARAGE_NONE; // TFIXME 原来是 garage_type == GARAGE_NONE,确认更改后无问题
|
2024-01-13 18:20:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|