3e78435897e33856dc9cb9a5a176019fa3cb1f82
[platform/upstream/opencv.git] / modules / dnn / src / init.cpp
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 #include "precomp.hpp"
43 #include <opencv2/dnn/layer.details.hpp>
44
45 #include <google/protobuf/stubs/common.h>
46
47 namespace cv {
48 namespace dnn {
49 CV__DNN_EXPERIMENTAL_NS_BEGIN
50
51 static Mutex* __initialization_mutex = NULL;
52 Mutex& getInitializationMutex()
53 {
54     if (__initialization_mutex == NULL)
55         __initialization_mutex = new Mutex();
56     return *__initialization_mutex;
57 }
58 // force initialization (single-threaded environment)
59 Mutex* __initialization_mutex_initializer = &getInitializationMutex();
60
61 namespace {
62 using namespace google::protobuf;
63 class ProtobufShutdown {
64 public:
65     bool initialized;
66     ProtobufShutdown() : initialized(true) {}
67     ~ProtobufShutdown()
68     {
69         initialized = false;
70         google::protobuf::ShutdownProtobufLibrary();
71     }
72 };
73 } // namespace
74
75 void initializeLayerFactory()
76 {
77     CV_TRACE_FUNCTION();
78
79     static ProtobufShutdown protobufShutdown; (void)protobufShutdown;
80
81     CV_DNN_REGISTER_LAYER_CLASS(Slice,          SliceLayer);
82     CV_DNN_REGISTER_LAYER_CLASS(Split,          SplitLayer);
83     CV_DNN_REGISTER_LAYER_CLASS(Concat,         ConcatLayer);
84     CV_DNN_REGISTER_LAYER_CLASS(Reshape,        ReshapeLayer);
85     CV_DNN_REGISTER_LAYER_CLASS(Flatten,        FlattenLayer);
86     CV_DNN_REGISTER_LAYER_CLASS(ResizeNearestNeighbor, ResizeNearestNeighborLayer);
87
88     CV_DNN_REGISTER_LAYER_CLASS(Convolution,    ConvolutionLayer);
89     CV_DNN_REGISTER_LAYER_CLASS(Deconvolution,  DeconvolutionLayer);
90     CV_DNN_REGISTER_LAYER_CLASS(Pooling,        PoolingLayer);
91     CV_DNN_REGISTER_LAYER_CLASS(ROIPooling,     PoolingLayer);
92     CV_DNN_REGISTER_LAYER_CLASS(LRN,            LRNLayer);
93     CV_DNN_REGISTER_LAYER_CLASS(InnerProduct,   InnerProductLayer);
94     CV_DNN_REGISTER_LAYER_CLASS(Softmax,        SoftmaxLayer);
95     CV_DNN_REGISTER_LAYER_CLASS(MVN,            MVNLayer);
96
97     CV_DNN_REGISTER_LAYER_CLASS(ReLU,           ReLULayer);
98     CV_DNN_REGISTER_LAYER_CLASS(ReLU6,          ReLU6Layer);
99     CV_DNN_REGISTER_LAYER_CLASS(ChannelsPReLU,  ChannelsPReLULayer);
100     CV_DNN_REGISTER_LAYER_CLASS(PReLU,          ChannelsPReLULayer);
101     CV_DNN_REGISTER_LAYER_CLASS(Sigmoid,        SigmoidLayer);
102     CV_DNN_REGISTER_LAYER_CLASS(TanH,           TanHLayer);
103     CV_DNN_REGISTER_LAYER_CLASS(ELU,            ELULayer);
104     CV_DNN_REGISTER_LAYER_CLASS(BNLL,           BNLLLayer);
105     CV_DNN_REGISTER_LAYER_CLASS(AbsVal,         AbsLayer);
106     CV_DNN_REGISTER_LAYER_CLASS(Power,          PowerLayer);
107     CV_DNN_REGISTER_LAYER_CLASS(BatchNorm,      BatchNormLayer);
108     CV_DNN_REGISTER_LAYER_CLASS(MaxUnpool,      MaxUnpoolLayer);
109     CV_DNN_REGISTER_LAYER_CLASS(Dropout,        BlankLayer);
110     CV_DNN_REGISTER_LAYER_CLASS(Identity,       BlankLayer);
111     CV_DNN_REGISTER_LAYER_CLASS(Silence,        BlankLayer);
112
113     CV_DNN_REGISTER_LAYER_CLASS(Crop,           CropLayer);
114     CV_DNN_REGISTER_LAYER_CLASS(Eltwise,        EltwiseLayer);
115     CV_DNN_REGISTER_LAYER_CLASS(Permute,        PermuteLayer);
116     CV_DNN_REGISTER_LAYER_CLASS(PriorBox,       PriorBoxLayer);
117     CV_DNN_REGISTER_LAYER_CLASS(PriorBoxClustered, PriorBoxLayer);
118     CV_DNN_REGISTER_LAYER_CLASS(Reorg,          ReorgLayer);
119     CV_DNN_REGISTER_LAYER_CLASS(Region,         RegionLayer);
120     CV_DNN_REGISTER_LAYER_CLASS(DetectionOutput, DetectionOutputLayer);
121     CV_DNN_REGISTER_LAYER_CLASS(NormalizeBBox,  NormalizeBBoxLayer);
122     CV_DNN_REGISTER_LAYER_CLASS(Normalize,      NormalizeBBoxLayer);
123     CV_DNN_REGISTER_LAYER_CLASS(Shift,          ShiftLayer);
124     CV_DNN_REGISTER_LAYER_CLASS(Padding,        PaddingLayer);
125     CV_DNN_REGISTER_LAYER_CLASS(Scale,          ScaleLayer);
126
127     CV_DNN_REGISTER_LAYER_CLASS(LSTM,           LSTMLayer);
128 }
129
130 CV__DNN_EXPERIMENTAL_NS_END
131 }} // namespace