Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/dnn/src/init.cpp
16337 views
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_INLINE_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; CV_UNUSED(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(Resize, ResizeLayer);
87
CV_DNN_REGISTER_LAYER_CLASS(Interp, InterpLayer);
88
CV_DNN_REGISTER_LAYER_CLASS(CropAndResize, CropAndResizeLayer);
89
90
CV_DNN_REGISTER_LAYER_CLASS(Convolution, ConvolutionLayer);
91
CV_DNN_REGISTER_LAYER_CLASS(Deconvolution, DeconvolutionLayer);
92
CV_DNN_REGISTER_LAYER_CLASS(Pooling, PoolingLayer);
93
CV_DNN_REGISTER_LAYER_CLASS(ROIPooling, PoolingLayer);
94
CV_DNN_REGISTER_LAYER_CLASS(PSROIPooling, PoolingLayer);
95
CV_DNN_REGISTER_LAYER_CLASS(LRN, LRNLayer);
96
CV_DNN_REGISTER_LAYER_CLASS(InnerProduct, InnerProductLayer);
97
CV_DNN_REGISTER_LAYER_CLASS(Softmax, SoftmaxLayer);
98
CV_DNN_REGISTER_LAYER_CLASS(MVN, MVNLayer);
99
100
CV_DNN_REGISTER_LAYER_CLASS(ReLU, ReLULayer);
101
CV_DNN_REGISTER_LAYER_CLASS(ReLU6, ReLU6Layer);
102
CV_DNN_REGISTER_LAYER_CLASS(ChannelsPReLU, ChannelsPReLULayer);
103
CV_DNN_REGISTER_LAYER_CLASS(PReLU, ChannelsPReLULayer);
104
CV_DNN_REGISTER_LAYER_CLASS(Sigmoid, SigmoidLayer);
105
CV_DNN_REGISTER_LAYER_CLASS(TanH, TanHLayer);
106
CV_DNN_REGISTER_LAYER_CLASS(ELU, ELULayer);
107
CV_DNN_REGISTER_LAYER_CLASS(BNLL, BNLLLayer);
108
CV_DNN_REGISTER_LAYER_CLASS(AbsVal, AbsLayer);
109
CV_DNN_REGISTER_LAYER_CLASS(Power, PowerLayer);
110
CV_DNN_REGISTER_LAYER_CLASS(BatchNorm, BatchNormLayer);
111
CV_DNN_REGISTER_LAYER_CLASS(MaxUnpool, MaxUnpoolLayer);
112
CV_DNN_REGISTER_LAYER_CLASS(Dropout, BlankLayer);
113
CV_DNN_REGISTER_LAYER_CLASS(Identity, BlankLayer);
114
CV_DNN_REGISTER_LAYER_CLASS(Silence, BlankLayer);
115
116
CV_DNN_REGISTER_LAYER_CLASS(Crop, CropLayer);
117
CV_DNN_REGISTER_LAYER_CLASS(Eltwise, EltwiseLayer);
118
CV_DNN_REGISTER_LAYER_CLASS(Permute, PermuteLayer);
119
CV_DNN_REGISTER_LAYER_CLASS(ShuffleChannel, ShuffleChannelLayer);
120
CV_DNN_REGISTER_LAYER_CLASS(PriorBox, PriorBoxLayer);
121
CV_DNN_REGISTER_LAYER_CLASS(PriorBoxClustered, PriorBoxLayer);
122
CV_DNN_REGISTER_LAYER_CLASS(Reorg, ReorgLayer);
123
CV_DNN_REGISTER_LAYER_CLASS(Region, RegionLayer);
124
CV_DNN_REGISTER_LAYER_CLASS(DetectionOutput, DetectionOutputLayer);
125
CV_DNN_REGISTER_LAYER_CLASS(NormalizeBBox, NormalizeBBoxLayer);
126
CV_DNN_REGISTER_LAYER_CLASS(Normalize, NormalizeBBoxLayer);
127
CV_DNN_REGISTER_LAYER_CLASS(Shift, ShiftLayer);
128
CV_DNN_REGISTER_LAYER_CLASS(Padding, PaddingLayer);
129
CV_DNN_REGISTER_LAYER_CLASS(Proposal, ProposalLayer);
130
CV_DNN_REGISTER_LAYER_CLASS(Scale, ScaleLayer);
131
132
CV_DNN_REGISTER_LAYER_CLASS(LSTM, LSTMLayer);
133
}
134
135
CV__DNN_INLINE_NS_END
136
}} // namespace
137
138