forked from Alexoner/vehicle-assistance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.h
54 lines (44 loc) · 1.33 KB
/
utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*************************************************************************
> File Name: utils.h
> Author: onerhao
> Mail: haodu@hustunique.com
> Created Time: Sun 17 Mar 2013 10:56:35 PM CST
************************************************************************/
#ifndef UTILS_H
#define UTILS_H
#include <math.h>
#include <cv.h>
class Line
{
public:
CvPoint p0,p1;
float angle,k,b,length;
int votes;
bool visited,found;
public:
Line();
Line(CvPoint p0,CvPoint p1);
Line(float k,float b);
virtual double getx(float y);
virtual double gety(float x);
bool operator <(const Line &l) const
{
return (this->length < l.length);
}
virtual ~Line();
};
//return slope of the line formed by two points
extern double calSlope(CvPoint p0,CvPoint p1);
//return the slope angle of the line formed by two points
extern double calSlopeAngle(CvPoint p0,CvPoint p1);
//return the intercept of line y=k*x+b
extern double calIntercept(CvPoint p0,CvPoint p1);
//return of the lenght of two points
extern double calLength(CvPoint p0,CvPoint p1);
//return the middle point
extern CvPoint midPoint(CvPoint p0,CvPoint p1);
//return intersection of two line
extern CvPoint calIntersection(Line l0,Line l1);
//check whether a point is in the *** formed by the pts
extern int pointIn(CvPoint pt,std::vector<CvPoint>& pts);
#endif