energy changed

This commit is contained in:
sun
2019-07-11 23:22:23 +08:00
parent a2f08e9674
commit d65093216a
12 changed files with 135 additions and 137 deletions

View File

@@ -25,6 +25,7 @@ class Energy {
public:
Energy(Serial &u, uint8_t &color);//构造函数,参数为串口和敌方颜色
~Energy();//默认析构函数
int runBig(cv::Mat &gimble_src, cv::Mat &chassis_src);
int runBig(cv::Mat &gimble_src);
@@ -46,14 +47,7 @@ private:
bool isChassis;//同时具有底盘和云台摄像头时,处于底盘摄像头击打过程
bool isGuessing;//当前处于发弹到新目标出现的过程则为true此时猜测下一个目标
bool isPredicting;//当前处于新目标出现到发弹的过程则为true此时正常击打
// int fans_cnt;//图像中的扇叶个数
// int armors_cnt;//图像中的装甲板个数
// int centerRs_cnt;//图像中可能的风车中心字母R选区个数
// int flow_strip_fans_cnt;//图像中的含流动条扇叶个数
// int flow_strips_cnt;//图像中的流动条个数
int last_fans_cnt;//上一帧的扇叶个数
int last_flow_strip_fans_cnt;//上一帧的含流动条扇叶个数
int last_flow_strips_cnt;//上一帧的流动条个数
double radius;//大风车半径
float target_polar_angle;//待击打装甲板的极坐标角度
float last_target_polar_angle;//上一帧待击打装甲板的极坐标角度
@@ -76,16 +70,14 @@ private:
float target_cnt;//用于记录寻找到的装甲板总数,该值变化则立即中断主控板发射进程,防止重复击打已点亮的装甲板
bool save_new_mark;//若操作手进行过手动标定则为true
bool shoot;//若为true则要求主控板发弹
int guess_devide;
bool startguessing;
int guess_devide;//刚进入猜测状态时,猜测目标点在极坐标中的分区
bool startguessing;//进入猜测状态的标志
timeval time_start_guess;
std::vector<cv::RotatedRect> fans;//图像中所有扇叶
std::vector<cv::RotatedRect> armors;//图像中所有可能装甲板(可能存在误识别)
// std::vector<cv::RotatedRect> centerRs;//风车中心字母R的可能候选区
// std::vector<cv::RotatedRect> flow_strips;//图像中所有流动条(理论上只有一个)
// std::vector<cv::RotatedRect> flow_strip_fans;//图像中所有流动条所在扇叶(理论上只有一个)
// std::vector<cv::RotatedRect> center_ROI;//风车中心候选区
// std::vector<cv::RotatedRect> target_armor;//目标装甲板(理论上仅一个)
cv::RotatedRect centerR;//风车中心字母R的可能候选区
cv::RotatedRect flow_strip;//图像中所有流动条(理论上只有一个)
cv::RotatedRect flow_strip_fan;//图像中所有流动条所在扇叶(理论上只有一个)
@@ -140,21 +132,22 @@ private:
void findTargetByIntersection();//通过面积重合度匹配获取目标装甲板的极坐标角度和装甲板中心坐标
bool findTargetInFlowStripFan();//在已发现的流动条区域中寻找待击打装甲板
void rotate();//获取预测点位
void rotate(cv::Point target_point);//获取预测点位
void stretch(cv::Point point_1, cv::Point2f &point_2);//将像素差转换为实际距离差
double pointDistance(cv::Point point_1, cv::Point point_2);//计算两点距离
int devide(float angle);//将极坐标分为五个区域,判断一个角度处于哪个区域
int linePointX(const cv::Point2f &p1, const cv::Point2f &p2, int y);//计算直线上一点横坐标
double nonZeroRateOfRotateRect(const cv::Mat &bin, const cv::RotatedRect &rotatedRect);//计算旋转矩形内亮点占比
double pointDistance(cv::Point point_1, cv::Point point_2);//计算两点距离
double nonZeroRateOfRotateRect(cv::Mat &bin, const cv::RotatedRect &rotatedRect);//计算旋转矩形内亮点占比
void writeDownMark();//记录操作手标定的云台初始角度
void getTargetPolarAngle();
void getPredictPoint();//获取预测点位
void getAimPoint();//通过自瞄逻辑计算点位
void getPredictPoint(cv::Point target_point);//获取预测点位
void getAimPoint(cv::Point target_point);//通过自瞄逻辑计算点位
bool changeTarget();//判断目标是否改变
void changeMark();//操作手手动修改标定值
void gimbleRotation();//计算云台旋转角度
void getAllArmorCenters();//记录所有装甲板中心坐标
void judgeBigShoot();//判断大符模式是否可以发弹
void judgeSmallShoot();//判断小符模式是否可以发弹