diff --git a/CMakeLists.txt b/CMakeLists.txt index 06ca22b..8403ca2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ endif(NOT CMAKE_BUILD_TYPE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Werror -pedantic") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Werror -pedantic -pg") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -pedantic -D_DEBUG") diff --git a/geometry.cpp b/geometry.cpp index 456c1f3..18c3096 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -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 line, std::vector 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; } }