├── .gitignore ├── CMakeLists.txt ├── README.md ├── fix_lapack.patch ├── fix_python_discovery.patch ├── package.xml └── rename_unordered_map_definition.patch /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | # Precompiled Headers 7 | *.gch 8 | *.pch 9 | # Compiled Dynamic libraries 10 | *.so 11 | *.dylib 12 | *.dll 13 | # Fortran module files 14 | *.mod 15 | # Compiled Static libraries 16 | *.lai 17 | *.la 18 | *.a 19 | *.lib 20 | # Executables 21 | *.exe 22 | *.out 23 | *.app 24 | 25 | # Bloom. 26 | debian 27 | obj* 28 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.3) 2 | project(opencv3_catkin) 3 | 4 | find_package(catkin_simple REQUIRED) 5 | 6 | catkin_simple() 7 | 8 | include(ExternalProject) 9 | 10 | file(MAKE_DIRECTORY ${CATKIN_DEVEL_PREFIX}/include) 11 | 12 | SET(CONTRIB_NAME "opencv3_contrib") 13 | ExternalProject_Add(${CONTRIB_NAME} 14 | URL https://github.com/opencv/opencv_contrib/archive/3.4.2.zip 15 | URL_MD5 171a0c9eabbdc3332164de6221684beb 16 | SOURCE_DIR ${CONTRIB_NAME}_src 17 | UPDATE_COMMAND "" 18 | CONFIGURE_COMMAND "" 19 | BUILD_COMMAND "" 20 | INSTALL_COMMAND "" 21 | ) 22 | 23 | SET(OPENCV_SRC_PATH "opencv3_src") 24 | SET(OPENCV_BUILD_PATH "opencv3_build") 25 | ExternalProject_Add(opencv3_src 26 | DEPENDS ${CONTRIB_NAME} 27 | URL https://github.com/opencv/opencv/archive/3.4.2.zip 28 | URL_MD5 9e9ebe9c1fe98c468f6e53f5c3c49716 29 | UPDATE_COMMAND "" 30 | SOURCE_DIR ${OPENCV_SRC_PATH} 31 | BINARY_DIR ${OPENCV_BUILD_PATH} 32 | PATCH_COMMAND patch -p0 < ${CMAKE_SOURCE_DIR}/fix_python_discovery.patch && 33 | patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/rename_unordered_map_definition.patch 34 | CONFIGURE_COMMAND cd ../${OPENCV_BUILD_PATH} && cmake 35 | -DOPENCV_EXTRA_MODULES_PATH=../${CONTRIB_NAME}_src/modules . 36 | -DWITH_TBB=ON 37 | -DBUILD_opencv_python2=ON 38 | -DBUILD_opencv_python3=ON 39 | -DWITH_GTK_2_X=ON # Can't use GTK3 as it links against system protobuf. 40 | -DWITH_PROTOBUF=OFF # Disable custom build of protobuf, since starting with OpenCV 3.4.2 a custom version of 41 | # protobuf is always pulled and compiled, even if no enabled modules use it. 42 | -DWITH_V4L=ON 43 | -DINSTALL_C_EXAMPLES=OFF 44 | -DINSTALL_PYTHON_EXAMPLES=OFF 45 | -DBUILD_EXAMPLES=OFF 46 | -DWITH_QT=OFF # Needed by clang under Ubuntu 14.04 and GTK_WIDGET(cvGetWindowHandle(...)) with gcc (image_view) 47 | -DWITH_OPENGL=ON 48 | -DWITH_VTK=ON 49 | -DENABLE_PRECOMPILED_HEADERS=OFF 50 | -DCMAKE_INSTALL_PREFIX=${CATKIN_DEVEL_PREFIX} 51 | -DBUILD_SHARED_LIBS=ON 52 | -DWITH_CUDA=OFF 53 | -DWITH_OPENCL=OFF 54 | -DBUILD_TESTS=OFF 55 | -DBUILD_opencv_ts=OFF 56 | -DBUILD_TESTS=OFF 57 | # opencv_contrib packages 58 | -DBUILD_opencv_dnn=OFF # Pulls in the system protobuf as a dependency! 59 | -DBUILD_opencv_dnns_easily_fooled=OFF 60 | -DBUILD_opencv_cnn_3dobj=OFF 61 | -DBUILD_opencv_aruco=ON 62 | -DBUILD_opencv_bgsegm=OFF 63 | -DBUILD_opencv_bioinspired=OFF 64 | -DBUILD_opencv_ccalib=OFF 65 | -DBUILD_opencv_contrib_world=OFF 66 | -DBUILD_opencv_datasets=OFF 67 | -DBUILD_opencv_dpm=OFF 68 | -DBUILD_opencv_face=OFF 69 | -DBUILD_opencv_fuzzy=OFF 70 | -DBUILD_opencv_freetype=OFF 71 | -DBUILD_opencv_hdf=OFF 72 | -DBUILD_opencv_line_descriptor=ON 73 | -DBUILD_opencv_matlab=OFF 74 | -DBUILD_opencv_optflow=OFF 75 | -DBUILD_opencv_plot=OFF 76 | -DBUILD_opencv_reg=OFF 77 | -DBUILD_opencv_rgbd=ON 78 | -DBUILD_opencv_saliency=ON 79 | -DBUILD_opencv_sfm=OFF 80 | -DBUILD_opencv_stereo=OFF 81 | -DBUILD_opencv_structured_light=OFF 82 | -DBUILD_opencv_surface_matching=OFF 83 | -DBUILD_opencv_text=OFF 84 | -DBUILD_opencv_tracking=OFF 85 | -DBUILD_opencv_xfeatures2d=ON 86 | -DBUILD_opencv_ximgproc=ON 87 | -DBUILD_opencv_xobjdetect=OFF 88 | -DBUILD_opencv_nonfree=OFF 89 | -DBUILD_opencv_xphoto=OFF ../${OPENCV_SRC_PATH} 90 | BUILD_COMMAND cd ../${OPENCV_BUILD_PATH} && make -j8 91 | INSTALL_COMMAND cd ../${OPENCV_BUILD_PATH} && make install -j8 92 | ) 93 | 94 | install(DIRECTORY ${CATKIN_DEVEL_PREFIX}/include/opencv 95 | DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION} 96 | FILES_MATCHING PATTERN "*.h" 97 | PATTERN "*.hpp") 98 | install(DIRECTORY ${CATKIN_DEVEL_PREFIX}/include/opencv2 99 | DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION} 100 | FILES_MATCHING PATTERN "*.h" 101 | PATTERN "*.hpp") 102 | install(DIRECTORY ${CATKIN_DEVEL_PREFIX}/lib/ 103 | DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 104 | FILES_MATCHING PATTERN "libopencv*") 105 | install(DIRECTORY ${CATKIN_DEVEL_PREFIX}/share/OpenCV 106 | DESTINATION ${CATKIN_GLOBAL_SHARE_DESTINATION}) 107 | set(OPENCV_INSTALLED_EXECUTABLES 108 | opencv_annotation 109 | opencv_createsamples 110 | opencv_traincascade 111 | opencv_version 112 | opencv_visualisation 113 | ) 114 | 115 | foreach(installed_file ${OPENCV_INSTALLED_EXECUTABLES}) 116 | # Need to rename binaries as they will conflict with the binaries from 117 | # the ROS OpenCV package otherwise. 118 | string(REPLACE opencv opencv3_catkin new_file_name ${installed_file} ) 119 | install(FILES ${CATKIN_DEVEL_PREFIX}/bin/${installed_file} 120 | RENAME ${new_file_name} 121 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE 122 | DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) 123 | endforeach() 124 | 125 | cs_export(INCLUDE_DIRS ${CATKIN_DEVEL_PREFIX}/include 126 | LIBRARIES opencv_aruco 127 | opencv_calib3d 128 | opencv_core 129 | opencv_features2d 130 | opencv_flann 131 | opencv_highgui 132 | opencv_imgcodecs 133 | opencv_imgproc 134 | opencv_line_descriptor 135 | opencv_ml 136 | opencv_objdetect 137 | opencv_phase_unwrapping 138 | opencv_photo 139 | opencv_rgbd 140 | opencv_saliency 141 | opencv_shape 142 | opencv_stitching 143 | opencv_superres 144 | opencv_video 145 | opencv_videoio 146 | opencv_videostab 147 | opencv_viz 148 | opencv_xfeatures2d 149 | opencv_ximgproc 150 | ) 151 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | opencv3_catkin 2 | ============== 3 | 4 | Catkin wrapper for opencv3 5 | 6 | -------------------------------------------------------------------------------- /fix_lapack.patch: -------------------------------------------------------------------------------- 1 | From 2b44c0b6493726c465152e1db82cd8e65944d0db Mon Sep 17 00:00:00 2001 2 | From: Alexander Alekhin 3 | Date: Fri, 23 Dec 2016 14:50:33 +0300 4 | Subject: [PATCH 1/2] cmake: fix lapack 5 | 6 | - added compile check with multiple tries for different configurations 7 | - restored find_package(LAPACK) 8 | - avoided modification of OPENCV_LINKER_LIBS 9 | --- 10 | cmake/OpenCVFindLAPACK.cmake | 209 +++++++++++++++++++++++++++++------------- 11 | cmake/checks/lapack_check.cpp | 14 +++ 12 | modules/core/CMakeLists.txt | 2 +- 13 | 3 files changed, 160 insertions(+), 65 deletions(-) 14 | create mode 100644 cmake/checks/lapack_check.cpp 15 | 16 | diff --git cmake/OpenCVFindLAPACK.cmake cmake/OpenCVFindLAPACK.cmake 17 | index dfacf243284..0bee1b4c90f 100644 18 | --- cmake/OpenCVFindLAPACK.cmake 19 | +++ cmake/OpenCVFindLAPACK.cmake 20 | @@ -1,78 +1,159 @@ 21 | -macro(_find_file_in_dirs VAR NAME DIRS) 22 | - find_path(${VAR} ${NAME} ${DIRS} NO_DEFAULT_PATH) 23 | - set(${VAR} ${${VAR}}/${NAME}) 24 | - unset(${VAR} CACHE) 25 | +macro(_find_header_file_in_dirs VAR NAME) 26 | + unset(${VAR}) 27 | + unset(${VAR} CACHE) 28 | + if(" ${ARGN}" STREQUAL " ") 29 | + check_include_file("${NAME}" HAVE_${VAR}) 30 | + if(HAVE_${VAR}) 31 | + set(${VAR} "${NAME}") # fallback 32 | + else() 33 | + set(${VAR} "") 34 | + endif() 35 | + else() 36 | + find_path(${VAR} "${NAME}" ${ARGN} NO_DEFAULT_PATH) 37 | + if(${VAR}) 38 | + set(${VAR} "${${VAR}}/${NAME}") 39 | + unset(${VAR} CACHE) 40 | + else() 41 | + unset(${VAR} CACHE) 42 | + set(${VAR} "") 43 | + endif() 44 | + endif() 45 | +endmacro() 46 | + 47 | +macro(ocv_lapack_check) 48 | + string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" _lapack_impl "${LAPACK_IMPL}") 49 | + message(STATUS "LAPACK(${LAPACK_IMPL}): LAPACK_LIBRARIES: ${LAPACK_LIBRARIES}") 50 | + _find_header_file_in_dirs(OPENCV_CBLAS_H_PATH_${_lapack_impl} "${LAPACK_CBLAS_H}" "${LAPACK_INCLUDE_DIR}") 51 | + _find_header_file_in_dirs(OPENCV_LAPACKE_H_PATH_${_lapack_impl} "${LAPACK_LAPACKE_H}" "${LAPACK_INCLUDE_DIR}") 52 | + if(NOT OPENCV_CBLAS_H_PATH_${_lapack_impl} OR NOT OPENCV_LAPACKE_H_PATH_${_lapack_impl}) 53 | + message(WARNING "LAPACK(${LAPACK_IMPL}): CBLAS/LAPACK headers are not found in '${LAPACK_INCLUDE_DIR}'") 54 | + unset(LAPACK_LIBRARIES) 55 | + else() 56 | + # adding proxy opencv_lapack.h header 57 | + set(CBLAS_H_PROXY_PATH ${CMAKE_BINARY_DIR}/opencv_lapack.h) 58 | + set(_lapack_include_str "\#include \"${OPENCV_CBLAS_H_PATH_${_lapack_impl}}\"") 59 | + if(NOT "${OPENCV_CBLAS_H_PATH_${_lapack_impl}}" STREQUAL "${OPENCV_LAPACKE_H_PATH_${_lapack_impl}}") 60 | + set(_lapack_include_str "${_lapack_include_str}\n#include \"${OPENCV_LAPACKE_H_PATH_${_lapack_impl}}\"") 61 | + endif() 62 | + # update file contents (if required) 63 | + set(__content_str "") 64 | + if(EXISTS "${CBLAS_H_PROXY_PATH}") 65 | + file(READ "${CBLAS_H_PROXY_PATH}" __content_str) 66 | + endif() 67 | + if(NOT " ${__content_str}" STREQUAL " ${_lapack_include_str}") 68 | + file(WRITE "${CBLAS_H_PROXY_PATH}" "${_lapack_include_str}") 69 | + endif() 70 | + 71 | + try_compile(__VALID_LAPACK 72 | + "${OpenCV_BINARY_DIR}" 73 | + "${OpenCV_SOURCE_DIR}/cmake/checks/lapack_check.cpp" 74 | + CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${LAPACK_INCLUDE_DIR}\;${CMAKE_BINARY_DIR}" 75 | + "-DLINK_DIRECTORIES:STRING=${LAPACK_LINK_LIBRARIES}" 76 | + "-DLINK_LIBRARIES:STRING=${LAPACK_LIBRARIES}" 77 | + OUTPUT_VARIABLE TRY_OUT 78 | + ) 79 | + if(NOT __VALID_LAPACK) 80 | + #message(FATAL_ERROR "LAPACK: check build log:\n${TRY_OUT}") 81 | + message(STATUS "LAPACK(${LAPACK_IMPL}): Can't build LAPACK check code. This LAPACK version is not supported.") 82 | + unset(LAPACK_LIBRARIES) 83 | + else() 84 | + message(STATUS "LAPACK(${LAPACK_IMPL}): Support is enabled.") 85 | + ocv_include_directories(${LAPACK_INCLUDE_DIR}) 86 | + set(HAVE_LAPACK 1) 87 | + endif() 88 | + endif() 89 | endmacro() 90 | 91 | if(WITH_LAPACK) 92 | - ocv_update(LAPACK_IMPL "Unknown") 93 | - if(NOT LAPACK_LIBRARIES) 94 | - include(cmake/OpenCVFindMKL.cmake) 95 | - if(HAVE_MKL) 96 | - set(LAPACK_INCLUDE_DIR ${MKL_INCLUDE_DIRS}) 97 | - set(LAPACK_LIBRARIES ${MKL_LIBRARIES} ) 98 | - set(LAPACK_CBLAS_H "mkl_cblas.h" ) 99 | - set(LAPACK_LAPACKE_H "mkl_lapack.h" ) 100 | - set(LAPACK_IMPL "MKL") 101 | - endif() 102 | + ocv_update(LAPACK_IMPL "Unknown") 103 | + if(NOT OPENCV_LAPACK_FIND_PACKAGE_ONLY) 104 | + if(NOT LAPACK_LIBRARIES AND NOT OPENCV_LAPACK_DISABLE_MKL) 105 | + include(cmake/OpenCVFindMKL.cmake) 106 | + if(HAVE_MKL) 107 | + set(LAPACK_INCLUDE_DIR ${MKL_INCLUDE_DIRS}) 108 | + set(LAPACK_LIBRARIES ${MKL_LIBRARIES}) 109 | + set(LAPACK_CBLAS_H "mkl_cblas.h") 110 | + set(LAPACK_LAPACKE_H "mkl_lapack.h") 111 | + set(LAPACK_IMPL "MKL") 112 | + ocv_lapack_check() 113 | + endif() 114 | endif() 115 | if(NOT LAPACK_LIBRARIES) 116 | - include(cmake/OpenCVFindOpenBLAS.cmake) 117 | - if(OpenBLAS_FOUND) 118 | - set(LAPACK_INCLUDE_DIR ${OpenBLAS_INCLUDE_DIR} ) 119 | - set(LAPACK_LIBRARIES ${OpenBLAS_LIB} ) 120 | - set(LAPACK_CBLAS_H "cblas.h" ) 121 | - set(LAPACK_LAPACKE_H "lapacke.h" ) 122 | - set(LAPACK_IMPL "OpenBLAS") 123 | - endif() 124 | + include(cmake/OpenCVFindOpenBLAS.cmake) 125 | + if(OpenBLAS_FOUND) 126 | + set(LAPACK_INCLUDE_DIR ${OpenBLAS_INCLUDE_DIR}) 127 | + set(LAPACK_LIBRARIES ${OpenBLAS_LIB}) 128 | + set(LAPACK_CBLAS_H "cblas.h") 129 | + set(LAPACK_LAPACKE_H "lapacke.h") 130 | + set(LAPACK_IMPL "OpenBLAS") 131 | + ocv_lapack_check() 132 | + endif() 133 | endif() 134 | if(NOT LAPACK_LIBRARIES AND UNIX) 135 | - include(cmake/OpenCVFindAtlas.cmake) 136 | - if(ATLAS_FOUND) 137 | - set(LAPACK_INCLUDE_DIR ${Atlas_INCLUDE_DIR}) 138 | - set(LAPACK_LIBRARIES ${Atlas_LIBRARIES} ) 139 | - set(LAPACK_CBLAS_H "cblas.h" ) 140 | - set(LAPACK_LAPACKE_H "lapacke.h" ) 141 | - set(LAPACK_IMPL "Atlas") 142 | - endif() 143 | + include(cmake/OpenCVFindAtlas.cmake) 144 | + if(ATLAS_FOUND) 145 | + set(LAPACK_INCLUDE_DIR ${Atlas_INCLUDE_DIR}) 146 | + set(LAPACK_LIBRARIES ${Atlas_LIBRARIES}) 147 | + set(LAPACK_CBLAS_H "cblas.h") 148 | + set(LAPACK_LAPACKE_H "lapacke.h") 149 | + set(LAPACK_IMPL "Atlas") 150 | + ocv_lapack_check() 151 | + endif() 152 | endif() 153 | + endif() 154 | 155 | - if(NOT LAPACK_LIBRARIES AND APPLE) 156 | - set(LAPACK_INCLUDE_DIR "Accelerate") 157 | - set(LAPACK_LIBRARIES "-framework Accelerate") 158 | - set(LAPACK_CBLAS_H "cblas.h" ) 159 | - set(LAPACK_LAPACKE_H "lapacke.h" ) 160 | - set(LAPACK_IMPL "Apple") 161 | + if(NOT LAPACK_LIBRARIES) 162 | + if(WIN32 AND NOT OPENCV_LAPACK_SHARED_LIBS) 163 | + set(BLA_STATIC 1) 164 | + endif() 165 | + find_package(LAPACK) 166 | + if(LAPACK_FOUND) 167 | + if(NOT DEFINED LAPACKE_INCLUDE_DIR) 168 | + find_path(LAPACKE_INCLUDE_DIR "lapacke.h") 169 | + endif() 170 | + if(NOT DEFINED MKL_LAPACKE_INCLUDE_DIR) 171 | + find_path(MKL_LAPACKE_INCLUDE_DIR "mkl_lapack.h") 172 | + endif() 173 | + if(MKL_LAPACKE_INCLUDE_DIR AND NOT OPENCV_LAPACK_DISABLE_MKL) 174 | + set(LAPACK_INCLUDE_DIR ${MKL_LAPACKE_INCLUDE_DIR}) 175 | + set(LAPACK_CBLAS_H "mkl_cblas.h") 176 | + set(LAPACK_LAPACKE_H "mkl_lapack.h") 177 | + set(LAPACK_IMPL "LAPACK/MKL") 178 | + ocv_lapack_check() 179 | + endif() 180 | + if(LAPACKE_INCLUDE_DIR AND NOT HAVE_LAPACK) 181 | + set(LAPACK_INCLUDE_DIR ${LAPACKE_INCLUDE_DIR}) 182 | + set(LAPACK_CBLAS_H "cblas.h") 183 | + set(LAPACK_LAPACKE_H "lapacke.h") 184 | + set(LAPACK_IMPL "LAPACK/Generic") 185 | + ocv_lapack_check() 186 | + elseif(APPLE) 187 | + set(LAPACK_CBLAS_H "Accelerate/Accelerate.h") 188 | + set(LAPACK_LAPACKE_H "Accelerate/Accelerate.h") 189 | + set(LAPACK_IMPL "LAPACK/Apple") 190 | + ocv_lapack_check() 191 | + else() 192 | + unset(LAPACK_LIBRARIES CACHE) 193 | + endif() 194 | endif() 195 | + endif() 196 | 197 | - set(LAPACK_INCLUDE_DIR ${LAPACK_INCLUDE_DIR} CACHE PATH "Path to BLAS include dir" FORCE) 198 | - set(LAPACK_CBLAS_H ${LAPACK_CBLAS_H} CACHE STRING "Alternative name of cblas.h" FORCE) 199 | - set(LAPACK_LAPACKE_H ${LAPACK_LAPACKE_H} CACHE STRING "Alternative name of lapacke.h" FORCE) 200 | - set(LAPACK_LIBRARIES ${LAPACK_LIBRARIES} CACHE STRING "Names of BLAS & LAPACK binaries (.so, .dll, .a, .lib)" FORCE) 201 | - set(LAPACK_IMPL ${LAPACK_IMPL} CACHE STRING "Lapack implementation id" FORCE) 202 | + if(NOT LAPACK_LIBRARIES AND APPLE AND NOT OPENCV_LAPACK_FIND_PACKAGE_ONLY) 203 | + set(LAPACK_INCLUDE_DIR "") 204 | + set(LAPACK_LIBRARIES "-framework Accelerate") 205 | + set(LAPACK_CBLAS_H "Accelerate/Accelerate.h") 206 | + set(LAPACK_LAPACKE_H "Accelerate/Accelerate.h") 207 | + set(LAPACK_IMPL "Apple") 208 | + ocv_lapack_check() 209 | + endif() 210 | 211 | - if(LAPACK_LIBRARIES) #adding proxy cblas.h header 212 | - message(STATUS "LAPACK_IMPL: ${LAPACK_IMPL}, LAPACK_LIBRARIES: ${LAPACK_LIBRARIES}") 213 | - if("${LAPACK_IMPL}" STREQUAL "Apple") 214 | - set(CBLAS_H_PATH "Accelerate/Accelerate.h") 215 | - set(LAPACKE_H_PATH "Accelerate/Accelerate.h") 216 | - else() 217 | - _find_file_in_dirs(CBLAS_H_PATH "${LAPACK_CBLAS_H}" "${LAPACK_INCLUDE_DIR}") 218 | - _find_file_in_dirs(LAPACKE_H_PATH "${LAPACK_LAPACKE_H}" "${LAPACK_INCLUDE_DIR}") 219 | - endif() 220 | - if(NOT CBLAS_H_PATH OR NOT LAPACKE_H_PATH) 221 | - message(WARNING "CBLAS/LAPACK headers are not found in '${LAPACK_INCLUDE_DIR}'") 222 | - endif() 223 | - ocv_include_directories(${LAPACK_INCLUDE_DIR}) 224 | - list(APPEND OPENCV_LINKER_LIBS ${LAPACK_LIBRARIES}) 225 | - set(HAVE_LAPACK 1) 226 | + if(NOT HAVE_LAPACK AND LAPACK_LIBRARIES) 227 | + ocv_lapack_check() 228 | + endif() 229 | 230 | - set(CBLAS_H_PROXY_PATH ${CMAKE_BINARY_DIR}/opencv_lapack.h) 231 | - set(_include_str "\#include \"${CBLAS_H_PATH}\"") 232 | - if("${CBLAS_H_PATH}" STREQUAL "${LAPACKE_H_PATH}") 233 | - else() 234 | - set(_include_str "${_include_str}\n\#include \"${LAPACKE_H_PATH}\"") 235 | - endif() 236 | - file(WRITE ${CBLAS_H_PROXY_PATH} ${_include_str}) 237 | - endif() 238 | + set(LAPACK_INCLUDE_DIR ${LAPACK_INCLUDE_DIR} CACHE PATH "Path to BLAS include dir" FORCE) 239 | + set(LAPACK_CBLAS_H ${LAPACK_CBLAS_H} CACHE STRING "Alternative name of cblas.h" FORCE) 240 | + set(LAPACK_LAPACKE_H ${LAPACK_LAPACKE_H} CACHE STRING "Alternative name of lapacke.h" FORCE) 241 | + set(LAPACK_LIBRARIES ${LAPACK_LIBRARIES} CACHE STRING "Names of BLAS & LAPACK binaries (.so, .dll, .a, .lib)" FORCE) 242 | + set(LAPACK_IMPL ${LAPACK_IMPL} CACHE STRING "Lapack implementation id" FORCE) 243 | endif() 244 | diff --git cmake/checks/lapack_check.cpp cmake/checks/lapack_check.cpp 245 | new file mode 100644 246 | index 00000000000..0457c44d686 247 | --- /dev/null 248 | +++ cmake/checks/lapack_check.cpp 249 | @@ -0,0 +1,14 @@ 250 | +#include "opencv_lapack.h" 251 | + 252 | +static char* check_fn1 = (char*)sgesv_; 253 | +static char* check_fn2 = (char*)sposv_; 254 | +static char* check_fn3 = (char*)spotrf_; 255 | +static char* check_fn4 = (char*)sgesdd_; 256 | + 257 | +int main(int argc, char* argv[]) 258 | +{ 259 | + (void)argv; 260 | + if(argc > 1000) 261 | + return check_fn1[0] + check_fn2[0] + check_fn3[0] + check_fn4[0]; 262 | + return 0; 263 | +} 264 | diff --git modules/core/CMakeLists.txt modules/core/CMakeLists.txt 265 | index 0485a08ad3b..41da8254578 100644 266 | --- modules/core/CMakeLists.txt 267 | +++ modules/core/CMakeLists.txt 268 | @@ -1,7 +1,7 @@ 269 | set(the_description "The Core Functionality") 270 | ocv_add_module(core 271 | "${OPENCV_HAL_LINKER_LIBS}" 272 | - PRIVATE_REQUIRED ${ZLIB_LIBRARIES} "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}" 273 | + PRIVATE_REQUIRED ${ZLIB_LIBRARIES} "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}" "${LAPACK_LIBRARIES}" 274 | OPTIONAL opencv_cudev 275 | WRAP java python) 276 | 277 | 278 | From 3668a01fca0858c32b4083dfd0215eb7bd8fa263 Mon Sep 17 00:00:00 2001 279 | From: Alexander Alekhin 280 | Date: Tue, 17 Jan 2017 15:52:45 +0300 281 | Subject: [PATCH 2/2] eliminate warnings 282 | 283 | hal_internal.cpp(101): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data 284 | --- 285 | modules/core/src/hal_internal.cpp | 34 +++++++++++++++++----------------- 286 | 1 file changed, 17 insertions(+), 17 deletions(-) 287 | 288 | diff --git modules/core/src/hal_internal.cpp modules/core/src/hal_internal.cpp 289 | index b2b6dc36263..345ca42dc65 100644 290 | --- modules/core/src/hal_internal.cpp 291 | +++ modules/core/src/hal_internal.cpp 292 | @@ -98,7 +98,7 @@ set_value(fptype *dst, size_t dst_ld, fptype value, size_t m, size_t n) 293 | template static inline int 294 | lapack_LU(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n, int* info) 295 | { 296 | - int lda = a_step / sizeof(fptype), sign = 0; 297 | + int lda = (int)(a_step / sizeof(fptype)), sign = 0; 298 | int* piv = new int[m]; 299 | 300 | transpose_square_inplace(a, lda, m); 301 | @@ -114,7 +114,7 @@ lapack_LU(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n, int* 302 | } 303 | else 304 | { 305 | - int ldb = b_step / sizeof(fptype); 306 | + int ldb = (int)(b_step / sizeof(fptype)); 307 | fptype* tmpB = new fptype[m*n]; 308 | 309 | transpose(b, ldb, tmpB, m, m, n); 310 | @@ -153,7 +153,7 @@ template static inline int 311 | lapack_Cholesky(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n, bool* info) 312 | { 313 | int lapackStatus = 0; 314 | - int lda = a_step / sizeof(fptype); 315 | + int lda = (int)(a_step / sizeof(fptype)); 316 | char L[] = {'L', '\0'}; 317 | 318 | if(b) 319 | @@ -167,7 +167,7 @@ lapack_Cholesky(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n 320 | } 321 | else 322 | { 323 | - int ldb = b_step / sizeof(fptype); 324 | + int ldb = (int)(b_step / sizeof(fptype)); 325 | fptype* tmpB = new fptype[m*n]; 326 | transpose(b, ldb, tmpB, m, m, n); 327 | 328 | @@ -197,9 +197,9 @@ lapack_Cholesky(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n 329 | template static inline int 330 | lapack_SVD(fptype* a, size_t a_step, fptype *w, fptype* u, size_t u_step, fptype* vt, size_t v_step, int m, int n, int flags, int* info) 331 | { 332 | - int lda = a_step / sizeof(fptype); 333 | - int ldv = v_step / sizeof(fptype); 334 | - int ldu = u_step / sizeof(fptype); 335 | + int lda = (int)(a_step / sizeof(fptype)); 336 | + int ldv = (int)(v_step / sizeof(fptype)); 337 | + int ldu = (int)(u_step / sizeof(fptype)); 338 | int lwork = -1; 339 | int* iworkBuf = new int[8*std::min(m, n)]; 340 | fptype work1 = 0; 341 | @@ -256,7 +256,7 @@ lapack_SVD(fptype* a, size_t a_step, fptype *w, fptype* u, size_t u_step, fptype 342 | template static inline int 343 | lapack_QR(fptype* a, size_t a_step, int m, int n, int k, fptype* b, size_t b_step, fptype* dst, int* info) 344 | { 345 | - int lda = a_step / sizeof(fptype); 346 | + int lda = (int)(a_step / sizeof(fptype)); 347 | char mode[] = { 'N', '\0' }; 348 | if(m < n) 349 | return CV_HAL_ERROR_NOT_IMPLEMENTED; 350 | @@ -303,7 +303,7 @@ lapack_QR(fptype* a, size_t a_step, int m, int n, int k, fptype* b, size_t b_ste 351 | { 352 | std::vector tmpBMemHolder(m*k); 353 | fptype* tmpB = &tmpBMemHolder.front(); 354 | - int ldb = b_step / sizeof(fptype); 355 | + int ldb = (int)(b_step / sizeof(fptype)); 356 | transpose(b, ldb, tmpB, m, m, k); 357 | 358 | if (typeid(fptype) == typeid(float)) 359 | @@ -357,10 +357,10 @@ template static inline int 360 | lapack_gemm(const fptype *src1, size_t src1_step, const fptype *src2, size_t src2_step, fptype alpha, 361 | const fptype *src3, size_t src3_step, fptype beta, fptype *dst, size_t dst_step, int a_m, int a_n, int d_n, int flags) 362 | { 363 | - int ldsrc1 = src1_step / sizeof(fptype); 364 | - int ldsrc2 = src2_step / sizeof(fptype); 365 | - int ldsrc3 = src3_step / sizeof(fptype); 366 | - int lddst = dst_step / sizeof(fptype); 367 | + int ldsrc1 = (int)(src1_step / sizeof(fptype)); 368 | + int ldsrc2 = (int)(src2_step / sizeof(fptype)); 369 | + int ldsrc3 = (int)(src3_step / sizeof(fptype)); 370 | + int lddst = (int)(dst_step / sizeof(fptype)); 371 | int c_m, c_n, d_m; 372 | CBLAS_TRANSPOSE transA, transB; 373 | 374 | @@ -434,10 +434,10 @@ template static inline int 375 | lapack_gemm_c(const fptype *src1, size_t src1_step, const fptype *src2, size_t src2_step, fptype alpha, 376 | const fptype *src3, size_t src3_step, fptype beta, fptype *dst, size_t dst_step, int a_m, int a_n, int d_n, int flags) 377 | { 378 | - int ldsrc1 = src1_step / sizeof(std::complex); 379 | - int ldsrc2 = src2_step / sizeof(std::complex); 380 | - int ldsrc3 = src3_step / sizeof(std::complex); 381 | - int lddst = dst_step / sizeof(std::complex); 382 | + int ldsrc1 = (int)(src1_step / sizeof(std::complex)); 383 | + int ldsrc2 = (int)(src2_step / sizeof(std::complex)); 384 | + int ldsrc3 = (int)(src3_step / sizeof(std::complex)); 385 | + int lddst = (int)(dst_step / sizeof(std::complex)); 386 | int c_m, c_n, d_m; 387 | CBLAS_TRANSPOSE transA, transB; 388 | std::complex cAlpha(alpha, 0.0); 389 | -------------------------------------------------------------------------------- /fix_python_discovery.patch: -------------------------------------------------------------------------------- 1 | commit c596ddc7ca1929d740b78ba2ff953b2406041e04 2 | Author: Kevin Egger 3 | Date: Wed Nov 9 15:39:50 2016 +0100 4 | 5 | Turned error messages for Python numpy discovery off. 6 | 7 | diff --git cmake/OpenCVDetectPython.cmake b/cmake/OpenCVDetectPython.cmake 8 | index 6dec76f..fba147a 100644 9 | --- cmake/OpenCVDetectPython.cmake 10 | +++ cmake/OpenCVDetectPython.cmake 11 | @@ -177,6 +177,7 @@ if(NOT ${found}) 12 | execute_process(COMMAND "${_executable}" -c "import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print(os.pathsep.join(numpy.distutils.misc_util.get_numpy_include_dirs()))" 13 | RESULT_VARIABLE _numpy_process 14 | OUTPUT_VARIABLE _numpy_include_dirs 15 | + ERROR_QUIET 16 | OUTPUT_STRIP_TRAILING_WHITESPACE) 17 | 18 | if(NOT _numpy_process EQUAL 0) 19 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | opencv3_catkin 4 | 3.4.2 5 | opencv3_catkin 6 | Paul Furgale 7 | Paul Furgale 8 | New BSD 9 | 10 | catkin 11 | catkin_simple 12 | 13 | 14 | -------------------------------------------------------------------------------- /rename_unordered_map_definition.patch: -------------------------------------------------------------------------------- 1 | diff --git a/modules/flann/include/opencv2/flann/lsh_table.h b/modules/flann/include/opencv2/flann/lsh_table.h 2 | index 1db9960..671db6c 100644 3 | --- a/modules/flann/include/opencv2/flann/lsh_table.h 4 | +++ b/modules/flann/include/opencv2/flann/lsh_table.h 5 | @@ -39,13 +39,13 @@ 6 | #include 7 | #include 8 | #include 9 | -// TODO as soon as we use C++0x, use the code in USE_UNORDERED_MAP 10 | +// TODO as soon as we use C++0x, use the code in CV_USE_UNORDERED_MAP 11 | #ifdef __GXX_EXPERIMENTAL_CXX0X__ 12 | -# define USE_UNORDERED_MAP 1 13 | +# define CV_USE_UNORDERED_MAP 1 14 | #else 15 | -# define USE_UNORDERED_MAP 0 16 | +# define CV_USE_UNORDERED_MAP 0 17 | #endif 18 | -#if USE_UNORDERED_MAP 19 | +#if CV_USE_UNORDERED_MAP 20 | #include 21 | #else 22 | #include 23 | @@ -132,7 +132,7 @@ class LshTable 24 | public: 25 | /** A container of all the feature indices. Optimized for space 26 | */ 27 | -#if USE_UNORDERED_MAP 28 | +#if CV_USE_UNORDERED_MAP 29 | typedef std::unordered_map BucketsSpace; 30 | #else 31 | typedef std::map BucketsSpace; 32 | @@ -197,7 +197,7 @@ public: 33 | */ 34 | void add(Matrix dataset) 35 | { 36 | -#if USE_UNORDERED_MAP 37 | +#if CV_USE_UNORDERED_MAP 38 | buckets_space_.rehash((buckets_space_.size() + dataset.rows) * 1.2); 39 | #endif 40 | // Add the features to the table 41 | --------------------------------------------------------------------------------