Skip to content

Commit 48924cd

Browse files
committed
Merge pull request opencv#8989 from alalek:move_dnn_module
2 parents b4f1102 + 986d27e commit 48924cd

File tree

138 files changed

+135176
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+135176
-0
lines changed

modules/dnn/CMakeLists.txt

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
if(WINRT)
2+
ocv_module_disable(dnn)
3+
endif()
4+
5+
include(${OpenCV_SOURCE_DIR}/cmake/OpenCVFindLibProtobuf.cmake)
6+
if(NOT Protobuf_FOUND)
7+
ocv_module_disable(opencv_dnn)
8+
endif()
9+
10+
set(the_description "Deep neural network module. It allows to load models from different frameworks and to make forward pass")
11+
12+
ocv_add_module(dnn opencv_core opencv_imgproc WRAP python matlab)
13+
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow -Wno-parentheses -Wmaybe-uninitialized -Wsign-promo
14+
-Wmissing-declarations -Wmissing-prototypes
15+
)
16+
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4701 /wd4100)
17+
18+
if(MSVC)
19+
add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 )
20+
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146
21+
/wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610
22+
/wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506
23+
)
24+
else()
25+
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow
26+
-Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo
27+
-Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra
28+
-Wunused-function -Wunused-const-variable -Wdeprecated-declarations
29+
)
30+
endif()
31+
32+
if(APPLE_FRAMEWORK)
33+
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshorten-64-to-32)
34+
endif()
35+
36+
if(ANDROID)
37+
add_definitions(-DDISABLE_POSIX_MEMALIGN -DTH_DISABLE_HEAP_TRACKING)
38+
endif()
39+
40+
#supress warnings in autogenerated caffe.pb.* files
41+
add_definitions(-DHAVE_PROTOBUF=1)
42+
ocv_warnings_disable(CMAKE_CXX_FLAGS
43+
-Wunused-parameter -Wundef -Wignored-qualifiers -Wno-enum-compare
44+
-Wdeprecated-declarations
45+
/wd4125 /wd4267 /wd4127 /wd4244 /wd4512 /wd4702
46+
/wd4456 /wd4510 /wd4610 /wd4800
47+
-wd858 -wd2196
48+
)
49+
50+
if(PROTOBUF_UPDATE_FILES)
51+
file(GLOB proto_files src/tensorflow/*.proto)
52+
list(APPEND proto_files src/caffe/caffe.proto)
53+
PROTOBUF_GENERATE_CPP(Protobuf_HDRS Protobuf_SRCS ${proto_files})
54+
else()
55+
file(GLOB fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.cc)
56+
file(GLOB fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.h)
57+
list(APPEND fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.cc)
58+
list(APPEND fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.h)
59+
list(APPEND Protobuf_SRCS ${fw_srcs})
60+
list(APPEND Protobuf_HDRS ${fw_hdrs})
61+
list(APPEND Protobuf_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe)
62+
list(APPEND Protobuf_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow)
63+
endif()
64+
65+
ocv_source_group("Src\\protobuf" FILES ${Protobuf_SRCS} ${Protobuf_HDRS})
66+
ocv_module_include_directories(include ${Protobuf_INCLUDE_DIRS})
67+
68+
ocv_glob_module_sources(${Protobuf_SRCS} ${Protobuf_HDRS} ${CBLAS_H_PROXY_PATH})
69+
ocv_create_module(${Protobuf_LIBRARIES} ${LAPACK_LIBRARIES})
70+
ocv_add_samples()
71+
ocv_add_accuracy_tests()
72+
ocv_add_perf_tests()
73+
74+
# ----------------------------------------------------------------------------
75+
# Torch7 importer of blobs and models, produced by Torch.nn module
76+
# ----------------------------------------------------------------------------
77+
OCV_OPTION(${the_module}_BUILD_TORCH_IMPORTER "Build Torch model importer" ON)
78+
if(${the_module}_BUILD_TORCH_IMPORTER)
79+
message(STATUS "Torch importer has been enabled. To run the tests you have to install Torch "
80+
"('th' executable should be available) "
81+
"and generate testdata using opencv_extra/testdata/dnn/generate_torch_models.py script.")
82+
add_definitions(-DENABLE_TORCH_IMPORTER=1)
83+
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702 /wd4127 /wd4267) #supress warnings in original torch files
84+
endif()

modules/dnn/include/opencv2/dnn.hpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*M///////////////////////////////////////////////////////////////////////////////////////
2+
//
3+
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4+
//
5+
// By downloading, copying, installing or using the software you agree to this license.
6+
// If you do not agree to this license, do not download, install,
7+
// copy or use the software.
8+
//
9+
//
10+
// License Agreement
11+
// For Open Source Computer Vision Library
12+
//
13+
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
14+
// Third party copyrights are property of their respective owners.
15+
//
16+
// Redistribution and use in source and binary forms, with or without modification,
17+
// are permitted provided that the following conditions are met:
18+
//
19+
// * Redistribution's of source code must retain the above copyright notice,
20+
// this list of conditions and the following disclaimer.
21+
//
22+
// * Redistribution's in binary form must reproduce the above copyright notice,
23+
// this list of conditions and the following disclaimer in the documentation
24+
// and/or other materials provided with the distribution.
25+
//
26+
// * The name of the copyright holders may not be used to endorse or promote products
27+
// derived from this software without specific prior written permission.
28+
//
29+
// This software is provided by the copyright holders and contributors "as is" and
30+
// any express or implied warranties, including, but not limited to, the implied
31+
// warranties of merchantability and fitness for a particular purpose are disclaimed.
32+
// In no event shall the Intel Corporation or contributors be liable for any direct,
33+
// indirect, incidental, special, exemplary, or consequential damages
34+
// (including, but not limited to, procurement of substitute goods or services;
35+
// loss of use, data, or profits; or business interruption) however caused
36+
// and on any theory of liability, whether in contract, strict liability,
37+
// or tort (including negligence or otherwise) arising in any way out of
38+
// the use of this software, even if advised of the possibility of such damage.
39+
//
40+
//M*/
41+
42+
#ifndef OPENCV_DNN_HPP
43+
#define OPENCV_DNN_HPP
44+
45+
// This is an umbrealla header to include into you project.
46+
// We are free to change headers layout in dnn subfolder, so please include
47+
// this header for future compartibility
48+
49+
50+
/** @defgroup dnn Deep Neural Network module
51+
@{
52+
This module contains:
53+
- API for new layers creation, layers are building bricks of neural networks;
54+
- set of built-in most-useful Layers;
55+
- API to constuct and modify comprehensive neural networks from layers;
56+
- functionality for loading serialized networks models from differnet frameworks.
57+
58+
Functionality of this module is designed only for forward pass computations (i. e. network testing).
59+
A network training is in principle not supported.
60+
@}
61+
*/
62+
#include <opencv2/dnn/dnn.hpp>
63+
64+
#endif /* OPENCV_DNN_HPP */

0 commit comments

Comments
 (0)