win32 ver

This commit is contained in:
xinyang
2019-05-15 16:32:30 +08:00
parent 6980145e83
commit 0d6aae81b8
7 changed files with 46 additions and 39 deletions

View File

@@ -28,14 +28,14 @@ void Energy::StructingElementErodeDilate(cv::Mat &src) {
// imshow("dilate_1", src);
erode(src,src, element_erode_1);
imshow("erode_1", src);
// imshow("erode_1", src);
dilate(src, src, element_dilate_2);
imshow("dilate_2", src);
// imshow("dilate_2", src);
erode(src,src, element_erode_2);
imshow("erode_2", src);
// imshow("erode_2", src);
dilate(src, src, element_dilate_3);
imshow("dilate_3", src);
// imshow("dilate_3", src);
}

View File

@@ -19,7 +19,8 @@ int Energy::findFan(const cv::Mat &src, vector<EnergyPart> &fans, int &last_fans
std::vector<vector<Point> > fan_contours;
StructingElementClose(src_bin,6,6);
imshow("fan struct",src_bin);
// imshow("fan struct",src_bin);
findContours(src_bin, fan_contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
@@ -72,7 +73,7 @@ int Energy::findArmor(const cv::Mat &src, vector<EnergyPart> &armors, int &last_
StructingElementErodeDilate(src_bin);
// StructingElementClose(src_bin,10,10);
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);

View File

@@ -16,38 +16,38 @@ void Energy::gimbleRotation(){
cv::Point2f real_hit_point;
stretch(hit_point, real_hit_point);
float origin_yaw = -0.13;
float origin_pitch = 13.18;
/*origin_yaw = mark_yaw;
origin_pitch = mark_pitch;*/
if(position_mode == 1){
yaw_rotation = static_cast<float>(180 / PI * atan2((attack_distance * tan(mark_yaw * PI / 180) - real_hit_point.x), attack_distance));
pitch_rotation = static_cast<float>(180 / PI * atan2((attack_distance*tan(mark_pitch*PI/180)-real_hit_point.y), attack_distance));
yaw_rotation = static_cast<float>(180 / PI * atan2((attack_distance * tan(origin_yaw * PI / 180) - real_hit_point.x), attack_distance));
pitch_rotation = static_cast<float>(180 / PI * atan2((attack_distance*tan(origin_pitch*PI/180)-real_hit_point.y), attack_distance));
}
else if(position_mode == 2){
yaw_rotation = static_cast<float>(180 / PI * atan2((attack_distance * tan(mark_yaw * PI / 180) - real_hit_point.x), attack_distance));
pitch_rotation = static_cast<float>(180 / PI * atan2((attack_distance*tan(mark_pitch*PI/180)-real_hit_point.y), attack_distance));
yaw_rotation = static_cast<float>(180 / PI * atan2((attack_distance * tan(origin_yaw * PI / 180) - real_hit_point.x), attack_distance));
pitch_rotation = static_cast<float>(180 / PI * atan2((attack_distance*tan(origin_pitch*PI/180)-real_hit_point.y), attack_distance));
}
else if(position_mode == 3){
yaw_rotation = static_cast<float>(180 / PI * atan2((attack_distance * tan(mark_yaw * PI / 180) - real_hit_point.x), attack_distance));
pitch_rotation = static_cast<float>(180 / PI * atan2((attack_distance*tan(mark_pitch*PI/180)-real_hit_point.y), attack_distance));
yaw_rotation = static_cast<float>(180 / PI * atan2((attack_distance * tan(origin_yaw * PI / 180) - real_hit_point.x), attack_distance));
pitch_rotation = static_cast<float>(180 / PI * atan2((attack_distance*tan(origin_pitch*PI/180)-real_hit_point.y), attack_distance));
}
else if(position_mode == 4){
yaw_rotation = static_cast<float>(180 / PI * atan2((attack_distance * tan(mark_yaw * PI / 180) - real_hit_point.x), attack_distance));
pitch_rotation = static_cast<float>(180 / PI * atan2((attack_distance*tan(mark_pitch*PI/180)-real_hit_point.y), attack_distance));
yaw_rotation = static_cast<float>(180 / PI * atan2((attack_distance * tan(origin_yaw * PI / 180) - real_hit_point.x), attack_distance));
pitch_rotation = static_cast<float>(180 / PI * atan2((attack_distance*tan(origin_pitch*PI/180)-real_hit_point.y), attack_distance));
}
else if(position_mode == 5){
yaw_rotation = static_cast<float>(180 / PI * atan2((attack_distance * tan(mark_yaw * PI / 180) - real_hit_point.x), attack_distance));
pitch_rotation = static_cast<float>(180 / PI * atan2((attack_distance*tan(mark_pitch*PI/180)-real_hit_point.y), attack_distance));
yaw_rotation = static_cast<float>(180 / PI * atan2((attack_distance * tan(origin_yaw * PI / 180) - real_hit_point.x), attack_distance));
pitch_rotation = static_cast<float>(180 / PI * atan2((attack_distance*tan(origin_pitch*PI/180)-real_hit_point.y), attack_distance));
}
else if(position_mode == 6){
yaw_rotation = static_cast<float>(180 / PI * atan2((attack_distance * tan(mark_yaw * PI / 180) - real_hit_point.x), attack_distance));
pitch_rotation = static_cast<float>(180 / PI * atan2((attack_distance*tan(mark_pitch*PI/180)-real_hit_point.y), attack_distance));
yaw_rotation = static_cast<float>(180 / PI * atan2((attack_distance * tan(origin_yaw * PI / 180) - real_hit_point.x), attack_distance));
pitch_rotation = static_cast<float>(180 / PI * atan2((attack_distance*tan(origin_pitch*PI/180)-real_hit_point.y), attack_distance));
}
// else{
// pitch_rotation = 5.5+static_cast<float>(180 / PI * atan2((attack_distance*tan(mark_pitch*PI/180)-real_hit_point.y), attack_distance));
// }
// yaw_rotation = static_cast<float>(180 / PI * atan2((ATTACK_DISTANCE*tan(3.5*PI/180)-STRETCH*(hit_point.x-cycle_center.x)), ATTACK_DISTANCE));
// pitch_rotation = static_cast<float>(180 / PI * atan2((ATTACK_DISTANCE*tan(9.1*PI/180)-STRETCH*(hit_point.y-cycle_center.y)), ATTACK_DISTANCE));
// cout<<"cur: "<<curr_yaw<<endl;
// cout<<"hit point: "<<hit_point<<'\t'<<"cycle center: "<<cycle_center<<endl;
}

View File

@@ -20,7 +20,7 @@ int Energy::run(cv::Mat &src){
gimble_zero_points.clear();
isSendTarget = false;
if(mark==0)return 0;
//if(mark==0)return 0;
// if(all_armor_centers.size()>200)all_armor_centers.clear();
// if(first_armor_centers.size()>200)first_armor_centers.clear();
@@ -30,7 +30,7 @@ int Energy::run(cv::Mat &src){
// imshow("img_preprocess",src);
threshold(src, src, energy_part_param_.GRAY_THRESH, 255, THRESH_BINARY);
imshow("bin",src);
// imshow("bin",src);
fans_cnt = findFan(src, fans, last_fans_cnt);
@@ -54,7 +54,10 @@ int Energy::run(cv::Mat &src){
// cycle_center = cv::Point(335, 246);
// radius = 116.936;
attack_distance = ATTACK_DISTANCE * 120/ radius;
// attack_distance = ATTACK_DISTANCE * 120/ radius;
attack_distance = 794 + 1245 * 75 * (1/radius - 1/113.9);
// cout << "attack distance: " << attack_distance << endl;
getFanPosition(fanPosition, fans, cycle_center, radius);
getArmorPosition(armorPosition, armors, cycle_center, radius);