33 #include <opencv2/core/core.hpp>
34 #include <opencv2/imgproc/imgproc.hpp>
35 #include <boost/shared_ptr.hpp>
36 #include <Eigen/Dense>
40 using namespace Eigen;
55 for(uint i=0 ; i<end_points.size() ; i++)
57 double x1 = end_points[i][0];
58 double y1 = end_points[i][1];
59 double x2 = end_points[i][2];
60 double y2 = end_points[i][3];
62 double th = atan2(x1-x2,y2-y1);
63 double rho = x1*cos(th) + y1*sin(th);
72 void extractInterval(
double rho_max,
double rho_min,
double theta_max,
double theta_min)
74 vector<Vec4i> end_points_local;
75 vector<double> rhos_local;
76 vector<double> thetas_local;
79 for(uint i=0;i<end_points.size();i++)
81 if(thetas[i]>theta_min && thetas[i]<theta_max)
83 end_points_local.push_back(end_points[i]);
84 rhos_local.push_back(rhos[i]);
85 thetas_local.push_back(thetas[i]);
90 end_points=end_points_local;
100 extreme_points.resize(20,4);
101 extreme_points.setOnes();
103 for (uint i=0; i<20 ; i++)
104 extreme_points(i,3) = 2;
106 for (uint i=0 ; i<end_points.size() ; i++)
109 P1 << end_points[i][0] , end_points[i][1];
110 P2 << end_points[i][2] , end_points[i][3];
135 if (thetas[i]!=0 && thetas[i]!=
PI)
139 k = ( (double)Py-(
double)P1(1) )/( (
double)P2(1)-(double)P1(1) );
140 Px = P1(0) + k*(P2(0)-P1(0));
142 if (Px<=cols && Px>=0)
144 extreme_points(i,0) = Px;
145 extreme_points(i,1) = Py;
150 k = ( (double)Py-(
double)P1(1) )/( (
double)P2(1)-(double)P1(1) );
151 Px = P1(0) + k*(P2(0)-P1(0));
153 if (Px<=cols && Px>=0)
155 extreme_points(i,0) = Px;
156 extreme_points(i,1) = Py;
161 if (thetas[i]!=(
PI/2) && thetas[i]!=(-
PI/2) )
165 k = ( (double)Px-(
double)P1(0) )/( (
double)P2(0)-(double)P1(0) );
166 Py = P1(1) + k*(P2(1)-P1(1));
169 extreme_points(i,2) = Px;
170 extreme_points(i,3) = Py;
174 k = ( (double)Px-(
double)P1(0) )/( (
double)P2(0)-(double)P1(0) );
175 Py = P1(1) + k*(P2(1)-P1(1));
179 extreme_points(i,2) = Px;
180 extreme_points(i,3) = Py;
187 return extreme_points;
MatrixXi extremePoints(int rows, int cols)
vector< Vec4i > end_points
void extractInterval(double rho_max, double rho_min, double theta_max, double theta_min)
void calculatePolarCoodinates(void)