|
@@ -9,6 +9,9 @@ using namespace cv;
|
|
|
|
|
|
#include "geometry.h"
|
|
|
|
|
|
+#define likely(x) __builtin_expect(!!(x), 1)
|
|
|
+#define unlikely(x) __builtin_expect(!!(x), 0)
|
|
|
+
|
|
|
double dist(Point a, Point b)
|
|
|
{
|
|
|
return sqrt((double)pow(a.x-b.x,2)+pow(a.y-b.y,2));
|
|
@@ -115,16 +118,13 @@ cv::Point
|
|
|
further_point_from_line(cv::Vec<double,3> line, std::vector<Point> points)
|
|
|
{
|
|
|
//distance = abs(a*p.x+b*p.y+c) / sqrt(a^2+b^2)
|
|
|
- double denom = sqrt(line(0)*line(0)+line(1)*line(1));
|
|
|
Point further = points[0];
|
|
|
double maxdist = -1;
|
|
|
- std::cout << "--- further" << std::endl;
|
|
|
for(Point p: points)
|
|
|
{
|
|
|
double numerator = abs(line(0)*p.x + line(1)*p.y + line(2));
|
|
|
- double distance = numerator/denom;
|
|
|
- if(distance > maxdist) {
|
|
|
- maxdist = distance;
|
|
|
+ if(numerator > maxdist) {
|
|
|
+ maxdist = numerator;
|
|
|
further = p;
|
|
|
}
|
|
|
}
|