删除不必要代码。
This commit is contained in:
@@ -6,13 +6,6 @@
|
||||
#include <additions.h>
|
||||
#include <log.h>
|
||||
|
||||
static double boxDistance(const cv::Rect2d &a, const cv::Rect2d &b) {
|
||||
cv::Point2d centerA(a.x + a.width / 2, a.y + a.height / 2);
|
||||
cv::Point2d centerB(b.x + b.width / 2, b.y + b.height / 2);
|
||||
auto dist = centerA - centerB;
|
||||
return sqrt(dist.x * dist.x + dist.y * dist.y);
|
||||
}
|
||||
|
||||
template<int length>
|
||||
static double mean(RoundQueue<double, length> &vec) {
|
||||
double sum = 0;
|
||||
@@ -22,63 +15,6 @@ static double mean(RoundQueue<double, length> &vec) {
|
||||
return sum / length;
|
||||
}
|
||||
|
||||
ArmorFinder::BoxRatioChangeType ArmorFinder::getRatioChangeType(RoundQueue<double, 5> &vec) {
|
||||
auto d = (vec[0] - vec[1] + vec[3] + vec[4]);
|
||||
if (d > 0.15) {
|
||||
return INCREASE;
|
||||
} else if (d < -0.15) {
|
||||
return DECREASE;
|
||||
} else {
|
||||
return NOCHANGE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void ArmorFinder::antiTop() {
|
||||
if (target_box.rect == cv::Rect2d()) return;
|
||||
uint16_t shoot_delay = 0;
|
||||
auto interval = getTimeIntervalms(frame_time, last_front_time);
|
||||
box_ratioes.push(target_box.rect.width / target_box.rect.height);
|
||||
auto change_type = getRatioChangeType(box_ratioes);
|
||||
auto orientation = target_box.getOrientation();
|
||||
if (interval > 700) {
|
||||
anti_top_cnt = 0;
|
||||
if (anti_top_state == ANTI_TOP) {
|
||||
anti_top_state = NORMAL;
|
||||
LOGM(STR_CTR(WORD_YELLOW, "switch to normal"));
|
||||
}
|
||||
}
|
||||
if (change_type == INCREASE && last_ratio_type != change_type) {
|
||||
last_front_time = frame_time;
|
||||
if (150 < interval && interval < 700) {
|
||||
if (anti_top_state == ANTI_TOP) {
|
||||
top_periodms.push(interval);
|
||||
LOGM(STR_CTR(WORD_LIGHT_GREEN, "top period: %.1lf ms"), interval);
|
||||
systime curr_time;
|
||||
getsystime(curr_time);
|
||||
auto calculate_time = getTimeIntervalms(curr_time, frame_time);
|
||||
shoot_delay = mean(top_periodms) - calculate_time;
|
||||
} else if (anti_top_state == NORMAL) {
|
||||
if (++anti_top_cnt > 4) {
|
||||
anti_top_state = ANTI_TOP;
|
||||
LOGM(STR_CTR(WORD_CYAN, "switch to anti-top"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (change_type != NOCHANGE) {
|
||||
last_ratio_type = change_type;
|
||||
}
|
||||
if (anti_top_state == ANTI_TOP) {
|
||||
if (orientation == ArmorBox::FRONT) {
|
||||
sendBoxPosition(shoot_delay);
|
||||
}
|
||||
} else if (anti_top_state == NORMAL) {
|
||||
sendBoxPosition(shoot_delay);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void ArmorFinder::antiTop() {
|
||||
if (target_box.rect == cv::Rect2d()) return;
|
||||
uint16_t shoot_delay = 0;
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
#include <log.h>
|
||||
|
||||
bool ArmorFinder::stateSearchingTarget(cv::Mat &src) {
|
||||
// if(anti_switch_cnt >= 3){
|
||||
// last_box = ArmorBox();
|
||||
// anti_switch_cnt = 0;
|
||||
// }
|
||||
if (findArmorBox(src, target_box)) {
|
||||
if (last_box.rect != cv::Rect2d() &&
|
||||
(getPointLength(last_box.getCenter() - target_box.getCenter()) > last_box.rect.height * 2.0) &&
|
||||
|
||||
Reference in New Issue
Block a user