31 Line::Line(
float params[4])
45 const vector<int>& corners,
46 const vector<PointInt >& edge,
50 for(
unsigned j = 0; j < corners.size(); ++j)
52 int start, end, first;
53 int size = (int)edge.size();
58 if(j < corners.size()-1)
68 len = size-start+end+1;
71 double* data =
new double[2*len];
74 CvMat* line_data = cvCreateMat(1, len, CV_32FC2);
75 for(
int i = 0; i < len; ++i)
81 double px = double(edge[ind].
x);
82 double py = double(edge[ind].
y);
83 CV_MAT_ELEM(*line_data, CvPoint2D32f, 0, i) = cvPoint2D32f(px, py);
86 float params[4] = {0};
87 cvFitLine(line_data, CV_DIST_L2, 0, 0.01, 0.01, params);
88 lines.push_back(
Line(params));
91 cvReleaseMat(&line_data);
105 double wx = l2.
c.x-l1.
c.x;
106 double wy = l2.
c.y-l1.
c.y;
109 double tmp = vx*uy-vy*ux;
114 s = (vy*wx-vx*wy) / (tmp);
PointDouble s
Direction vector.
This file implements a parametrized line.
int FitLines(vector< Line > &lines, const vector< int > &corners, const vector< PointInt > &edge, IplImage *grey)
TFSIMD_FORCE_INLINE const tfScalar & y() const
Struct representing a line. The line is parametrized by its center and direction vector.
TFSIMD_FORCE_INLINE const tfScalar & x() const
PointDouble ALVAR_EXPORT Intersection(const Line &l1, const Line &l2)
Calculates an intersection point of two lines.
ALVAR_EXPORT Point< CvPoint2D64f > PointDouble
The default double point type.
PointDouble c
Line center.