反陀螺v2.0
This commit is contained in:
@@ -15,7 +15,7 @@ struct McuData {
|
||||
float curr_pitch;
|
||||
uint8_t state;
|
||||
uint8_t mark;
|
||||
uint8_t use_classifier;
|
||||
uint8_t anti_top;
|
||||
uint8_t enemy_color;
|
||||
int delta_x;
|
||||
int delta_y;
|
||||
@@ -41,7 +41,7 @@ void extract(cv::Mat &gimbal_src, cv::Mat &chassis_src);
|
||||
|
||||
void extract(cv::Mat &gimbal_src);
|
||||
|
||||
float getTimeIntervalms(const systime &now, const systime &last);
|
||||
double getTimeIntervalms(const systime &now, const systime &last);
|
||||
|
||||
double getPointLength(const cv::Point2f &p);
|
||||
|
||||
|
||||
@@ -5,12 +5,15 @@
|
||||
#ifndef _PLATFORM_H_
|
||||
#define _PLATFORM_H_
|
||||
|
||||
typedef struct{
|
||||
int second;
|
||||
int millisecond;
|
||||
} systime;
|
||||
//typedef struct{
|
||||
// float second;
|
||||
// float millisecond;
|
||||
//} systime;
|
||||
|
||||
typedef double systime;
|
||||
|
||||
void getsystime(systime &t);
|
||||
double getTimeIntervalms(const systime &now, const systime &last);
|
||||
|
||||
#if defined(Linux) || defined(Darwin)
|
||||
#include <sys/time.h>
|
||||
|
||||
@@ -173,10 +173,6 @@ void extract(cv::Mat &gimbal_src) {//图像预处理,将视频切成640×480
|
||||
}
|
||||
}
|
||||
|
||||
float getTimeIntervalms(const systime &now, const systime &last){
|
||||
return (now.second-last.second)*1000.0 + (now.millisecond-last.millisecond);
|
||||
}
|
||||
|
||||
double getPointLength(const cv::Point2f &p) {
|
||||
return sqrt(p.x * p.x + p.y * p.y);
|
||||
}
|
||||
|
||||
@@ -5,11 +5,17 @@
|
||||
|
||||
#if defined(Linux) || defined(Darwin)
|
||||
|
||||
void getsystime(systime &t){
|
||||
static systime getsystime(){
|
||||
timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
t.second = tv.tv_sec;
|
||||
t.millisecond = tv.tv_usec/1000;
|
||||
return tv.tv_usec / 1000.0 + tv.tv_sec * 1000.0;
|
||||
}
|
||||
|
||||
void getsystime(systime &t) {
|
||||
static systime time_base = getsystime();
|
||||
timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
t = tv.tv_usec / 1000.0 + tv.tv_sec * 1000.0 - time_base;
|
||||
}
|
||||
|
||||
#elif defined(Windows)
|
||||
@@ -17,10 +23,14 @@ void getsystime(systime &t){
|
||||
void getsystime(systime &t){
|
||||
SYSTEMTIME tv;
|
||||
GetLocalTime(&tv);
|
||||
t.second = tv.wSecond;
|
||||
t.millisecond = tv.wMilliseconds;
|
||||
t = tv.wMilliseconds + tv.wSecond * 1000.0;
|
||||
}
|
||||
|
||||
#else
|
||||
#error "nonsupport platform."
|
||||
#error "nonsupport platform."
|
||||
#endif
|
||||
|
||||
|
||||
double getTimeIntervalms(const systime &now, const systime &last) {
|
||||
return now - last;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user