diff --git a/modules/dnn/src/init.cpp b/modules/dnn/src/init.cpp index 9222d5ecb1..97ea169f81 100644 --- a/modules/dnn/src/init.cpp +++ b/modules/dnn/src/init.cpp @@ -42,6 +42,8 @@ #include "precomp.hpp" #include +#include + namespace cv { namespace dnn { CV__DNN_EXPERIMENTAL_NS_BEGIN @@ -56,11 +58,26 @@ Mutex& getInitializationMutex() // force initialization (single-threaded environment) Mutex* __initialization_mutex_initializer = &getInitializationMutex(); +namespace { +using namespace google::protobuf; +class ProtobufShutdown { +public: + bool initialized; + ProtobufShutdown() : initialized(true) {} + ~ProtobufShutdown() + { + initialized = false; + google::protobuf::ShutdownProtobufLibrary(); + } +}; +} // namespace void initializeLayerFactory() { CV_TRACE_FUNCTION(); + static ProtobufShutdown protobufShutdown; (void)protobufShutdown; + CV_DNN_REGISTER_LAYER_CLASS(Slice, SliceLayer); CV_DNN_REGISTER_LAYER_CLASS(Split, SplitLayer); CV_DNN_REGISTER_LAYER_CLASS(Concat, ConcatLayer);