diff --git a/CMakeLists.txt b/CMakeLists.txt index 466094e..5d4916a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,10 +14,8 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -pedantic -D_D # Eigen library include_directories( "/usr/include/eigen3/" ) -# OpenCV -find_package( OpenCV 3.1 REQUIRED ) -# CUDA +# CUDA (optional) find_package( CUDA ) if (CUDA_FOUND) include( FindCUDA ) @@ -27,5 +25,18 @@ else() message(STATUS "CUDA not found; will skip bs_dsp") endif (CUDA_FOUND) +# OpenCV +find_package( OpenCV REQUIRED ) +if(OpenCV_VERSION VERSION_LESS "2.4.8") + message(FATAL_ERROR "ERROR: Can't find OpenCV 2.4.8+") +endif() +if(OpenCV_VERSION VERSION_LESS "3.0") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_OPENCV2") +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_OPENCV3") +endif (OpenCV_VERSION VERSION_LESS "3.0") + add_executable( lines lines.cpp ) target_link_libraries( lines ${OpenCV_LIBS} ) + +# vim: set et ts=4 sw=4: diff --git a/lines.cpp b/lines.cpp index baaecc1..717ea9f 100644 --- a/lines.cpp +++ b/lines.cpp @@ -1,6 +1,11 @@ #include #include -#include + +#ifdef HAS_OPENCV3 +#include //Any OPENCV3 code +#else +#include //Any Opencv2 code +#endif #include"lines.h" // all those colors are still visible on b/w (the first component is not so low) @@ -185,7 +190,7 @@ int main(int argc, char *argv[]) color = (color==BLUE) ? MAGENTA : BLUE; //flip color at every group cv::Point p1 = group[0]; cv::Point p2 = group[group.size()-1]; - cv::arrowedLine(img, p1, p2, color, dotwidth>>2); + cv::line(img, p1, p2, color, dotwidth>>2); std::cout << "simplified line: "; for(cv::Point p: group) {