energy changed
This commit is contained in:
@@ -69,8 +69,8 @@ void Energy::initEnergy() {
|
||||
// 此函数对能量机关参数进行初始化
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
void Energy::initEnergyPartParam() {
|
||||
// gimbal_energy_part_param_.GRAY_THRESH = 80;
|
||||
gimbal_energy_part_param_.GRAY_THRESH = 225;
|
||||
gimbal_energy_part_param_.GRAY_THRESH = 120;
|
||||
// gimbal_energy_part_param_.GRAY_THRESH = 225;
|
||||
gimbal_energy_part_param_.SPLIT_GRAY_THRESH = 230;
|
||||
gimbal_energy_part_param_.FAN_GRAY_THRESH = 75;
|
||||
gimbal_energy_part_param_.ARMOR_GRAY_THRESH = 80;
|
||||
@@ -141,8 +141,8 @@ void Energy::initEnergyPartParam() {
|
||||
|
||||
|
||||
|
||||
// chassis_energy_part_param_.GRAY_THRESH = 80;
|
||||
chassis_energy_part_param_.GRAY_THRESH = 225;
|
||||
chassis_energy_part_param_.GRAY_THRESH = 120;
|
||||
// chassis_energy_part_param_.GRAY_THRESH = 225;
|
||||
chassis_energy_part_param_.SPLIT_GRAY_THRESH = 230;
|
||||
chassis_energy_part_param_.FAN_GRAY_THRESH = 75;
|
||||
chassis_energy_part_param_.ARMOR_GRAY_THRESH = 80;
|
||||
@@ -199,12 +199,13 @@ void Energy::initEnergyPartParam() {
|
||||
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_AREA_MAX = 100000;
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_AREA_MIN = 0;
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_LENGTH_MIN = 50;
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_LENGTH_MAX = 90;
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_WIDTH_MIN = 3;
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_WIDTH_MAX = 20;
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_LENGTH_MIN = 55;
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_LENGTH_MAX = 95;
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_WIDTH_MIN = 13;
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_WIDTH_MAX = 35;
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_HW_RATIO_MAX = 12;
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_HW_RATIO_MIN = 4;
|
||||
// chassis_energy_part_param_.FLOW_STRIP_CONTOUR_HW_RATIO_MIN = 4;
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_HW_RATIO_MIN = 2.7;
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_AREA_RATIO_MIN = 0.5;
|
||||
chassis_energy_part_param_.FLOW_STRIP_CONTOUR_INTERSETION_AREA_MIN = 300;
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ int Energy::findArmors(const cv::Mat src) {
|
||||
std::vector<vector<Point> > armor_contours_external;//用总轮廓减去外轮廓,只保留内轮廓,除去流动条的影响。
|
||||
|
||||
ArmorStruct(src_bin);//图像膨胀,防止图像断开并更方便寻找
|
||||
imshow("armor struct", src_bin);
|
||||
// imshow("armor struct", src_bin);
|
||||
|
||||
findContours(src_bin, armor_contours, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
|
||||
// findContours(src_bin, armor_contours_external, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
|
||||
@@ -171,7 +171,7 @@ bool Energy::findFlowStripFan(const cv::Mat src) {
|
||||
}
|
||||
std::vector<vector<Point> > flow_strip_fan_contours;
|
||||
FlowStripFanStruct(src_bin);//图像膨胀,防止图像断开并更方便寻找
|
||||
imshow("flow strip fan struct", src_bin);
|
||||
// imshow("flow strip fan struct", src_bin);
|
||||
|
||||
findContours(src_bin, flow_strip_fan_contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
|
||||
|
||||
@@ -214,7 +214,7 @@ bool Energy::findFlowStrip(const cv::Mat src) {
|
||||
cvtColor(src_bin, src_bin, CV_BGR2GRAY);//若读取三通道视频文件,需转换为单通道
|
||||
}
|
||||
FlowStripStruct(src_bin);//图像膨胀,防止图像断开并更方便寻找
|
||||
// imshow("flow strip struct", src_bin);
|
||||
imshow("flow strip struct", src_bin);
|
||||
|
||||
std::vector<vector<Point> > flow_strip_contours;
|
||||
findContours(src_bin, flow_strip_contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
|
||||
@@ -228,10 +228,10 @@ bool Energy::findFlowStrip(const cv::Mat src) {
|
||||
// Size2f cur_size = cur_rect.size;
|
||||
// float length = cur_size.height > cur_size.width ? cur_size.height : cur_size.width;
|
||||
// float width = cur_size.height < cur_size.width ? cur_size.height : cur_size.width;
|
||||
// if (length > 20 && width > 5) {
|
||||
// if (length / width > 2 && width > 5) {
|
||||
// cout << cur_rect.center << endl;
|
||||
// flow_strip = cv::minAreaRect(flow_strip_contour);
|
||||
// cout << "flow strip fan area: " << length << '\t' << width << endl;
|
||||
// cout << "flow strip area: " << length << '\t' << width << endl;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ using namespace cv;
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
// 此函数通过自瞄逻辑击打目标点,用于大符的自动对心和小符直接打击
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
void Energy::getAimPoint(cv::Point target_point){
|
||||
double dx = target_point.x - 320;
|
||||
double dy = target_point.y - 240;
|
||||
yaw_rotation = atan(dx / FOCUS_PIXAL) * 180 / PI;
|
||||
void Energy::getAimPoint(cv::Point target_point) {
|
||||
double dx = -(target_point.x - 320 - 10);
|
||||
double dy = -(target_point.y - 240 - 22);
|
||||
yaw_rotation = atan(dx / FOCUS_PIXAL) * 180 / PI;
|
||||
pitch_rotation = atan(dy / FOCUS_PIXAL) * 180 / PI;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ void Energy::run(cv::Mat &gimbal_src, cv::Mat &chassis_src) {
|
||||
energy_part_param_ = gimbal_energy_part_param_;
|
||||
clearAll();
|
||||
initImage(gimbal_src);
|
||||
// findFans(gimbal_src);
|
||||
// showFans("fan",gimbal_src);
|
||||
|
||||
if (findArmors(gimbal_src) < 1)return;
|
||||
if (show_energy)showArmors("armor", gimbal_src);
|
||||
|
||||
@@ -17,6 +17,7 @@ void Energy::sendTarget(Serial& serial, float x, float y, float z){
|
||||
uint8_t buff[8];
|
||||
x_tmp = static_cast<short>(x * (32768 - 1) / 100);
|
||||
y_tmp = static_cast<short>(y * (32768 - 1) / 100);
|
||||
z_tmp = static_cast<short>(z * (32768 - 1) / 100);
|
||||
buff[0] = 's';
|
||||
buff[1] = static_cast<char>((x_tmp >> 8) & 0xFF);
|
||||
buff[2] = static_cast<char>((x_tmp >> 0) & 0xFF);
|
||||
|
||||
Reference in New Issue
Block a user