small change

This commit is contained in:
xinyang
2019-08-04 01:45:55 +08:00
parent 0b24c6a5af
commit bbe05a7db8

View File

@@ -81,18 +81,16 @@ void ArmorFinder::antiTop() {
void ArmorFinder::antiTop() { void ArmorFinder::antiTop() {
if (target_box.rect == cv::Rect2d()) return; if (target_box.rect == cv::Rect2d()) return;
static int fps = 0;
uint16_t shoot_delay = 0; uint16_t shoot_delay = 0;
auto interval = getTimeIntervalms(frame_time, last_front_time); auto interval = getTimeIntervalms(frame_time, last_front_time);
if (anti_top_state == ANTI_TOP && interval > 700) { if (anti_top_state == ANTI_TOP && interval > 500) {
anti_top_state = NORMAL; anti_top_state = NORMAL;
LOGM(STR_CTR(WORD_YELLOW, "switch to normal")); LOGM(STR_CTR(WORD_YELLOW, "switch to normal"));
} }
fps++;
if (last_box.rect != cv::Rect2d() && if (last_box.rect != cv::Rect2d() &&
getPointLength(last_box.getCenter() - target_box.getCenter()) > last_box.rect.height * 1.0) { getPointLength(last_box.getCenter() - target_box.getCenter()) > last_box.rect.height * 1.0) {
LOGM("switch %d! %lf", fps, getPointLength(last_box.getCenter() - target_box.getCenter()) / last_box.rect.height); LOGM("switch! %lf", getPointLength(last_box.getCenter() - target_box.getCenter()) / last_box.rect.height);
if (150 < interval && interval < 700) { if (150 < interval && interval < 500) {
if (anti_top_state == ANTI_TOP) { if (anti_top_state == ANTI_TOP) {
top_periodms.push(interval); top_periodms.push(interval);
LOGM(STR_CTR(WORD_LIGHT_GREEN, "top period: %.1lf ms"), interval); LOGM(STR_CTR(WORD_LIGHT_GREEN, "top period: %.1lf ms"), interval);
@@ -113,7 +111,7 @@ void ArmorFinder::antiTop() {
} }
if (anti_top_state == NORMAL) { if (anti_top_state == NORMAL) {
sendBoxPosition(0); sendBoxPosition(0);
} else if (interval < top_periodms[-1] * 0.2) { } else if (interval < top_periodms[-1] * 0.15) {
sendBoxPosition(0); sendBoxPosition(0);
} }
last_box = target_box; last_box = target_box;