OpenCV 4.5.3(日本語機械翻訳)
layer.details.hpp
1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
4 //
5 #ifndef OPENCV_DNN_LAYER_DETAILS_HPP
6 #define OPENCV_DNN_LAYER_DETAILS_HPP
7
8 #include <opencv2/dnn/layer.hpp>
9
10 namespace cv {
11 namespace dnn {
12CV__DNN_INLINE_NS_BEGIN
13
19 #define CV_DNN_REGISTER_LAYER_FUNC(type, constructorFunc) \
20 cv::dnn::LayerFactory::registerLayer(#type, constructorFunc);
21
27 #define CV_DNN_REGISTER_LAYER_CLASS(type, class) \
28 cv::dnn::LayerFactory::registerLayer(#type, cv::dnn::details::_layerDynamicRegisterer<class>);
29
35 #define CV_DNN_REGISTER_LAYER_FUNC_STATIC(type, constructorFunc) \
36 static cv::dnn::details::_LayerStaticRegisterer __LayerStaticRegisterer_##type(#type, constructorFunc);
37
43 #define CV_DNN_REGISTER_LAYER_CLASS_STATIC(type, class) \
44 Ptr<Layer> __LayerStaticRegisterer_func_##type(LayerParams &params) \
45 { return Ptr<Layer>(new class(params)); } \
46 static cv::dnn::details::_LayerStaticRegisterer __LayerStaticRegisterer_##type(#type, __LayerStaticRegisterer_func_##type);
47
48 namespace details {
49
50 template<typename LayerClass>
51Ptr<Layer> _layerDynamicRegisterer(LayerParams &params)
52{
53 return Ptr<Layer>(LayerClass::create(params));
54}
55
56 //allows automatically register created layer on module load time
58{
59 String type;
60 public:
61
62 _LayerStaticRegisterer(const String &layerType, LayerFactory::Constructor layerConstructor)
63 {
64 this->type = layerType;
65 LayerFactory::registerLayer(layerType, layerConstructor);
66 }
67
69 {
71 }
72};
73
74} // namespace
75CV__DNN_INLINE_NS_END
76}} // namespace
77
78 #endif
static void unregisterLayer(const String &type)
Unregisters registered layer with specified type name. Thread-safe.
static void registerLayer(const String &type, Constructor constructor)
Registers the layer class with typename type and specified constructor. Thread-safe.
Ptr< Layer >(* Constructor)(LayerParams &params)
Each Layer class must provide this function to the factory
Definition: layer.hpp:61
Definition: layer.details.hpp:58
cv
"black box" representation of the file storage associated with a file on disk.
Definition: aruco.hpp:75