|
|
|
@ -1,34 +1,38 @@ |
|
|
|
|
cmake_minimum_required(VERSION 2.8) |
|
|
|
|
|
|
|
|
|
macro(_dnn_do_protobuf_actions) |
|
|
|
|
option(WITH_PROTOBUF "Build with libprotobuf" ON) |
|
|
|
|
macro(_dnn_find_protobuf) |
|
|
|
|
|
|
|
|
|
if(NOT WITH_PROTOBUF) |
|
|
|
|
message(FATAL_ERROR "libprotobuf is required for dnn module") |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
find_package( Protobuf REQUIRED ) |
|
|
|
|
find_package( Protobuf ) |
|
|
|
|
|
|
|
|
|
if(EXISTS ${PROTOBUF_PROTOC_EXECUTABLE}) |
|
|
|
|
if(${PROTOBUF_FOUND} AND EXISTS ${PROTOBUF_PROTOC_EXECUTABLE}) |
|
|
|
|
message(STATUS "Found PROTOBUF Compiler: ${PROTOBUF_PROTOC_EXECUTABLE}") |
|
|
|
|
file(GLOB PROTO_FILES src/*.proto) |
|
|
|
|
PROTOBUF_GENERATE_CPP(PROTO_HDRS PROTO_SRCS ${PROTO_FILES}) |
|
|
|
|
set(HAVE_PROTOBUF ON) |
|
|
|
|
else() |
|
|
|
|
message(FATAL_ERROR "Could not find PROTOBUF Compiler") |
|
|
|
|
message(WARNING "PROTOBUF not found. Caffe import function will be disabled.") |
|
|
|
|
set(HAVE_PROTOBUF OFF) |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
file(GLOB PROTO_FILES src/*.proto) |
|
|
|
|
PROTOBUF_GENERATE_CPP(PROTO_HDRS PROTO_SRCS ${PROTO_FILES}) |
|
|
|
|
endmacro(_dnn_do_protobuf_actions) |
|
|
|
|
endmacro(_dnn_find_protobuf) |
|
|
|
|
|
|
|
|
|
if(BUILD_opencv_core)#it's build for OpenCV module |
|
|
|
|
_dnn_do_protobuf_actions() |
|
|
|
|
set(the_description "Deep neural network module. Allow load models and make forward pass") |
|
|
|
|
if(BUILD_opencv_core)#build as OpenCV module |
|
|
|
|
_dnn_find_protobuf() |
|
|
|
|
set(the_description "Deep neural network module. It allows to load models and to make forward pass") |
|
|
|
|
set(OPENCV_MODULE_IS_PART_OF_WORLD OFF) |
|
|
|
|
|
|
|
|
|
ocv_add_module(dnn opencv_imgproc opencv_core opencv_highgui WRAP python matlab) |
|
|
|
|
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow -Wno-parentheses) |
|
|
|
|
if(HAVE_PROTOBUF) |
|
|
|
|
add_definitions(-DHAVE_PROTOBUF 1) |
|
|
|
|
ocv_glob_module_sources(${PROTO_SRCS} ${PROTO_HDRS}) |
|
|
|
|
ocv_source_group("Src\\protobuf" FILES ${PROTO_SRCS} ${PROTO_HDRS}) |
|
|
|
|
ocv_module_include_directories(${PROTOBUF_INCLUDE_DIR} include src/caffe) |
|
|
|
|
else() |
|
|
|
|
file(GLOB NON_CAFFE_SOURCES "src/*.cpp" "src/layers/*.cpp") |
|
|
|
|
file(GLOB NON_CAFFE_HEADERS "src/*.hpp" "src/layers/*.hpp") |
|
|
|
|
ocv_set_module_sources(HEADERS ${NON_CAFFE_HEADERS} SOURCES ${NON_CAFFE_SOURCES}) |
|
|
|
|
endif() |
|
|
|
|
ocv_module_include_directories(include src/caffe ${PROTOBUF_INCLUDE_DIR}) |
|
|
|
|
|
|
|
|
|
ocv_create_module(${PROTOBUF_LIBRARIES}) |
|
|
|
|
|
|
|
|
@ -36,10 +40,10 @@ ocv_add_accuracy_tests() |
|
|
|
|
ocv_add_perf_tests() |
|
|
|
|
ocv_add_samples() |
|
|
|
|
|
|
|
|
|
else()#it's standalone module (development purposes) |
|
|
|
|
else()#build as standalone module (for development purposes) |
|
|
|
|
project(dnn_standalone) |
|
|
|
|
|
|
|
|
|
_dnn_do_protobuf_actions() |
|
|
|
|
_dnn_find_protobuf() |
|
|
|
|
find_package( OpenCV 3.0 REQUIRED ) |
|
|
|
|
|
|
|
|
|
file(GLOB_RECURSE MODULE_SOURCES "src/*.cpp") |
|
|
|
|