统一跨平台时间函数接口。
This commit is contained in:
@@ -6,13 +6,13 @@
|
||||
#define _ARMOR_FINDER_H_
|
||||
|
||||
#include <map>
|
||||
#include <sys/time.h>
|
||||
#include <systime.h>
|
||||
#include <constants.h>
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/tracking.hpp>
|
||||
#include <serial/serial.h>
|
||||
#include <serial.h>
|
||||
#include <armor_finder/classifier/classifier.h>
|
||||
#include <additions/additions.h>
|
||||
#include <additions.h>
|
||||
|
||||
#define BLOB_RED ENEMY_RED
|
||||
#define BLOB_BLUE ENEMY_BLUE
|
||||
@@ -111,7 +111,7 @@ private:
|
||||
INCREASE, DECREASE, NOCHANGE
|
||||
} BoxRatioChangeType;
|
||||
|
||||
timeval frame_time; // 当前帧对应时间;
|
||||
systime frame_time; // 当前帧对应时间;
|
||||
const uint8_t &enemy_color; // 敌方颜色,引用外部变量,自动变化
|
||||
State state; // 自瞄状态对象实例
|
||||
ArmorBox armor_box; // 当前目标装甲板
|
||||
@@ -123,7 +123,7 @@ private:
|
||||
const uint8_t &use_classifier; // 标记是否启用CNN分类器,引用外部变量,自动变化
|
||||
RoundQueue<double, 4> top_periodms;
|
||||
RoundQueue<double, 5> box_ratioes;
|
||||
timeval last_front_time; // 上一次发生装甲板方向切换的时间
|
||||
systime last_front_time; // 上一次发生装甲板方向切换的时间
|
||||
BoxRatioChangeType last_ratio_type;
|
||||
int anti_top_cnt; // 满足条件的装甲板方向切换持续次数,用于反陀螺
|
||||
AntiTopState anti_top_state; // 当前是否识别到陀螺
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
#include <armor_finder/armor_finder.h>
|
||||
#include <additions/additions.h>
|
||||
#include <additions.h>
|
||||
#include <log.h>
|
||||
|
||||
static double boxDistance(const cv::Rect2d &a, const cv::Rect2d &b) {
|
||||
@@ -53,8 +53,8 @@ void ArmorFinder::antiTop() {
|
||||
if (anti_top_state == ANTI_TOP) {
|
||||
top_periodms.push(interval);
|
||||
LOGM(STR_CTR(WORD_LIGHT_GREEN, "top period: %.1lf ms"), interval);
|
||||
timeval curr_time;
|
||||
gettimeofday(&curr_time, nullptr);
|
||||
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) {
|
||||
|
||||
@@ -17,11 +17,10 @@
|
||||
|
||||
#define LOG_LEVEL LOG_NONE
|
||||
#include <log.h>
|
||||
#include <options/options.h>
|
||||
#include <options.h>
|
||||
#include <show_images/show_images.h>
|
||||
#include <opencv2/highgui.hpp>
|
||||
#include <armor_finder/armor_finder.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
std::map<int, string> id2name = { //装甲板id到名称的map
|
||||
{-1, "OO"},{ 0, "NO"},
|
||||
@@ -58,7 +57,7 @@ ArmorFinder::ArmorFinder(uint8_t &color, Serial &u, const string ¶s_folder,
|
||||
}
|
||||
|
||||
void ArmorFinder::run(cv::Mat &src) {
|
||||
gettimeofday(&frame_time, nullptr);
|
||||
getsystime(frame_time);
|
||||
// stateSearchingTarget(src); // for debug
|
||||
// goto end;
|
||||
switch (state) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <armor_finder/armor_finder.h>
|
||||
#include <show_images/show_images.h>
|
||||
#include <options/options.h>
|
||||
#include <options.h>
|
||||
#include <opencv2/highgui.hpp>
|
||||
#define DO_NOT_CNT_TIME
|
||||
#include <log.h>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
#include <armor_finder/armor_finder.h>
|
||||
#include <options/options.h>
|
||||
#include <options.h>
|
||||
#include <opencv2/highgui.hpp>
|
||||
|
||||
static double lw_rate(const cv::RotatedRect &rect) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <armor_finder/armor_finder.h>
|
||||
#include <show_images/show_images.h>
|
||||
#include <options/options.h>
|
||||
#include <options.h>
|
||||
#include <log.h>
|
||||
|
||||
bool ArmorFinder::stateSearchingTarget(cv::Mat &src) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by xinyang on 19-3-27.
|
||||
//
|
||||
#include <log.h>
|
||||
#include <options/options.h>
|
||||
#include <options.h>
|
||||
#include <armor_finder/armor_finder.h>
|
||||
#include <show_images/show_images.h>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <show_images/show_images.h>
|
||||
#include <opencv2/highgui.hpp>
|
||||
#include <options/options.h>
|
||||
#include <options.h>
|
||||
#include <log.h>
|
||||
|
||||
using namespace cv;
|
||||
|
||||
Reference in New Issue
Block a user