2017-06-26 18:35:51 +08:00
|
|
|
if(WINRT)
|
|
|
|
ocv_module_disable(dnn)
|
|
|
|
endif()
|
|
|
|
|
2018-02-01 21:30:23 +08:00
|
|
|
if(NOT HAVE_PROTOBUF)
|
2017-06-26 18:35:51 +08:00
|
|
|
ocv_module_disable(opencv_dnn)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(the_description "Deep neural network module. It allows to load models from different frameworks and to make forward pass")
|
|
|
|
|
2018-02-12 19:48:20 +08:00
|
|
|
ocv_add_dispatched_file_force_all("layers/layers_common" AVX AVX2 AVX512_SKX)
|
2017-07-13 23:42:36 +08:00
|
|
|
|
2017-12-03 04:52:35 +08:00
|
|
|
ocv_add_module(dnn opencv_core opencv_imgproc WRAP python matlab java js)
|
2017-06-26 18:35:51 +08:00
|
|
|
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow -Wno-parentheses -Wmaybe-uninitialized -Wsign-promo
|
|
|
|
-Wmissing-declarations -Wmissing-prototypes
|
|
|
|
)
|
|
|
|
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4701 /wd4100)
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 )
|
|
|
|
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146
|
|
|
|
/wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610
|
|
|
|
/wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow
|
|
|
|
-Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo
|
|
|
|
-Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra
|
|
|
|
-Wunused-function -Wunused-const-variable -Wdeprecated-declarations
|
2018-02-06 16:57:35 +08:00
|
|
|
-Werror=non-virtual-dtor
|
2017-06-26 18:35:51 +08:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(APPLE_FRAMEWORK)
|
|
|
|
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshorten-64-to-32)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ANDROID)
|
|
|
|
add_definitions(-DDISABLE_POSIX_MEMALIGN -DTH_DISABLE_HEAP_TRACKING)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions(-DHAVE_PROTOBUF=1)
|
2018-02-01 21:30:23 +08:00
|
|
|
|
2018-02-12 20:07:39 +08:00
|
|
|
#suppress warnings in autogenerated caffe.pb.* files
|
2017-06-26 18:35:51 +08:00
|
|
|
ocv_warnings_disable(CMAKE_CXX_FLAGS
|
|
|
|
-Wunused-parameter -Wundef -Wignored-qualifiers -Wno-enum-compare
|
|
|
|
-Wdeprecated-declarations
|
|
|
|
/wd4125 /wd4267 /wd4127 /wd4244 /wd4512 /wd4702
|
|
|
|
/wd4456 /wd4510 /wd4610 /wd4800
|
2018-01-16 03:49:36 +08:00
|
|
|
/wd4701 /wd4703 # potentially uninitialized local/pointer variable 'value' used
|
|
|
|
/wd4505 # unreferenced local function has been removed
|
2017-06-26 18:35:51 +08:00
|
|
|
-wd858 -wd2196
|
2018-01-16 03:49:36 +08:00
|
|
|
-Winvalid-offsetof # Apple Clang (attr_value.pb.cc)
|
2017-06-26 18:35:51 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
if(PROTOBUF_UPDATE_FILES)
|
2018-02-03 02:52:54 +08:00
|
|
|
file(GLOB proto_files "${CMAKE_CURRENT_LIST_DIR}/src/tensorflow/*.proto" "${CMAKE_CURRENT_LIST_DIR}/src/caffe/opencv-caffe.proto")
|
2017-11-15 19:07:41 +08:00
|
|
|
set(PROTOBUF_GENERATE_CPP_APPEND_PATH ON) # required for tensorflow
|
2018-02-01 21:30:23 +08:00
|
|
|
protobuf_generate_cpp(fw_srcs fw_hdrs ${proto_files})
|
2017-06-26 18:35:51 +08:00
|
|
|
else()
|
2018-02-03 02:52:54 +08:00
|
|
|
file(GLOB fw_srcs "${CMAKE_CURRENT_LIST_DIR}/misc/tensorflow/*.cc" "${CMAKE_CURRENT_LIST_DIR}/misc/caffe/opencv-caffe.pb.cc")
|
|
|
|
file(GLOB fw_hdrs "${CMAKE_CURRENT_LIST_DIR}/misc/tensorflow/*.h" "${CMAKE_CURRENT_LIST_DIR}/misc/caffe/opencv-caffe.pb.h")
|
|
|
|
set(fw_inc "${CMAKE_CURRENT_LIST_DIR}/misc/caffe" "${CMAKE_CURRENT_LIST_DIR}/misc/tensorflow")
|
2017-06-26 18:35:51 +08:00
|
|
|
endif()
|
|
|
|
|
2018-02-03 02:52:54 +08:00
|
|
|
ocv_module_include_directories(${fw_inc} ${CMAKE_CURRENT_LIST_DIR}/src/ocl4dnn/include ${OPENCL_INCLUDE_DIRS})
|
2018-02-01 21:30:23 +08:00
|
|
|
ocv_glob_module_sources(SOURCES ${fw_srcs})
|
|
|
|
ocv_create_module(libprotobuf ${LAPACK_LIBRARIES})
|
2017-06-26 18:35:51 +08:00
|
|
|
ocv_add_samples()
|
|
|
|
ocv_add_accuracy_tests()
|
|
|
|
ocv_add_perf_tests()
|
|
|
|
|
2017-08-04 20:09:57 +08:00
|
|
|
ocv_option(${the_module}_PERF_CAFFE "Add performance tests of Caffe framework" OFF)
|
|
|
|
ocv_option(${the_module}_PERF_CLCAFFE "Add performance tests of clCaffe framework" OFF)
|
|
|
|
if(BUILD_PERF_TESTS)
|
|
|
|
if (${the_module}_PERF_CAFFE)
|
|
|
|
find_package(Caffe QUIET)
|
|
|
|
if (Caffe_FOUND)
|
|
|
|
add_definitions(-DHAVE_CAFFE=1)
|
|
|
|
ocv_target_link_libraries(opencv_perf_dnn caffe)
|
|
|
|
endif()
|
|
|
|
elseif(${the_module}_PERF_CLCAFFE)
|
|
|
|
find_package(Caffe QUIET)
|
|
|
|
if (Caffe_FOUND)
|
|
|
|
add_definitions(-DHAVE_CLCAFFE=1)
|
|
|
|
ocv_target_link_libraries(opencv_perf_dnn caffe)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|