Commit d126a7ca authored by oscar's avatar oscar

修改5个点是否计算轨迹的逻辑

parent 7660e684
......@@ -7,7 +7,7 @@
#include <opencv2/opencv.hpp>
#include <algorithm>
#define DIST_THRED 1
#define DIST_THRED 0.5
double calc_tangent_direction(const std::vector<point2d>& points) {
if (points.size() < 5) {
......@@ -79,21 +79,21 @@ int IsClosePoint(std::vector<point2d>& points)
{
if (points.size() != 5)
return 1;
float lenAllX = fabs(points[0].x - points[1].x) + fabs(points[0].x - points[2].x) + fabs(points[0].x - points[3].x) + fabs(points[0].x - points[4].x);
float lenX = fabs(points[0].x - points[4].x);
float lenAllY = fabs(points[0].y - points[1].y) + fabs(points[0].y - points[2].y) + fabs(points[0].y - points[3].y) + fabs(points[0].y - points[4].y);
float lenY = fabs(points[0].y - points[4].y);
if(lenX > DIST_THRED)
float len01 = sqrt(pow(points[0].x - points[1].x,2) + pow(points[0].y - points[1].y,2));
float len02 = sqrt(pow(points[0].x - points[2].x,2) + pow(points[0].y - points[2].y,2));
float len03 = sqrt(pow(points[0].x - points[3].x,2) + pow(points[0].y - points[3].y,2));
float len04 = sqrt(pow(points[0].x - points[4].x,2) + pow(points[0].y - points[4].y,2));
float lenAll = len01 + len02 + len03 + len04;
int isFar = 0;
if(len04 > DIST_THRED)
{
float rateX = lenAllX/lenX;
if(rateX > 1.75 && rateX < 2.25)
return 0;
float rateX = lenAll/len04;
if(rateX > 1.5 && rateX < 2.5)
isFar = 1;
}
if(lenY > DIST_THRED)
if(isFar == 1)
{
float rateY = lenAllY/lenY;
if(rateY > 1.75 && rateY < 2.25)
return 0;
return 0;
}
return 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment