Commit f1a56cb4 authored by Maksim Shabunin's avatar Maksim Shabunin

Merge pull request #9028 from alalek:dnn_experimental_namespace

parents 9087778b da096032
...@@ -43,10 +43,9 @@ ...@@ -43,10 +43,9 @@
#define OPENCV_DNN_DNN_ALL_LAYERS_HPP #define OPENCV_DNN_DNN_ALL_LAYERS_HPP
#include <opencv2/dnn.hpp> #include <opencv2/dnn.hpp>
namespace cv namespace cv {
{ namespace dnn {
namespace dnn CV__DNN_EXPERIMENTAL_NS_BEGIN
{
//! @addtogroup dnn //! @addtogroup dnn
//! @{ //! @{
...@@ -459,7 +458,7 @@ namespace dnn ...@@ -459,7 +458,7 @@ namespace dnn
//! @} //! @}
//! @} //! @}
CV__DNN_EXPERIMENTAL_NS_END
} }
} }
#endif #endif
...@@ -46,10 +46,9 @@ ...@@ -46,10 +46,9 @@
#include <map> #include <map>
#include <ostream> #include <ostream>
namespace cv namespace cv {
{ namespace dnn {
namespace dnn CV__DNN_EXPERIMENTAL_NS_BEGIN
{
//! @addtogroup dnn //! @addtogroup dnn
//! @{ //! @{
...@@ -140,6 +139,7 @@ public: ...@@ -140,6 +139,7 @@ public:
}; };
//! @} //! @}
CV__DNN_EXPERIMENTAL_NS_END
} }
} }
......
...@@ -44,12 +44,23 @@ ...@@ -44,12 +44,23 @@
#include <vector> #include <vector>
#include <opencv2/core.hpp> #include <opencv2/core.hpp>
#if !defined CV_DOXYGEN && !defined CV_DNN_DONT_ADD_EXPERIMENTAL_NS
#define CV__DNN_EXPERIMENTAL_NS_USE using namespace experimental_dnn_v1;
#define CV__DNN_EXPERIMENTAL_NS_BEGIN namespace experimental_dnn_v1 {
#define CV__DNN_EXPERIMENTAL_NS_END }
#else
#define CV__DNN_EXPERIMENTAL_NS_USE
#define CV__DNN_EXPERIMENTAL_NS_BEGIN
#define CV__DNN_EXPERIMENTAL_NS_END
#endif
#include <opencv2/dnn/dict.hpp> #include <opencv2/dnn/dict.hpp>
namespace cv namespace cv {
{ namespace dnn {
namespace dnn //! This namespace is used for dnn module functionlaity. CV__DNN_EXPERIMENTAL_NS_USE
{ CV__DNN_EXPERIMENTAL_NS_BEGIN
//! @addtogroup dnn //! @addtogroup dnn
//! @{ //! @{
...@@ -658,6 +669,7 @@ namespace dnn //! This namespace is used for dnn module functionlaity. ...@@ -658,6 +669,7 @@ namespace dnn //! This namespace is used for dnn module functionlaity.
Size size = Size(), const Scalar& mean = Scalar(), bool swapRB=true); Size size = Size(), const Scalar& mean = Scalar(), bool swapRB=true);
//! @} //! @}
CV__DNN_EXPERIMENTAL_NS_END
} }
} }
......
...@@ -44,10 +44,9 @@ ...@@ -44,10 +44,9 @@
#include <opencv2/dnn.hpp> #include <opencv2/dnn.hpp>
namespace cv namespace cv {
{ namespace dnn {
namespace dnn CV__DNN_EXPERIMENTAL_NS_BEGIN
{
template<typename TypeIter> template<typename TypeIter>
DictValue DictValue::arrayInt(TypeIter begin, int size) DictValue DictValue::arrayInt(TypeIter begin, int size)
...@@ -351,6 +350,7 @@ inline std::ostream &operator<<(std::ostream &stream, const Dict &dict) ...@@ -351,6 +350,7 @@ inline std::ostream &operator<<(std::ostream &stream, const Dict &dict)
return stream; return stream;
} }
CV__DNN_EXPERIMENTAL_NS_END
} }
} }
......
...@@ -7,10 +7,9 @@ ...@@ -7,10 +7,9 @@
#include <opencv2/dnn/layer.hpp> #include <opencv2/dnn/layer.hpp>
namespace cv namespace cv {
{ namespace dnn {
namespace dnn CV__DNN_EXPERIMENTAL_NS_BEGIN
{
/** @brief Registers layer constructor in runtime. /** @brief Registers layer constructor in runtime.
* @param type string, containing type name of the layer. * @param type string, containing type name of the layer.
...@@ -72,6 +71,8 @@ public: ...@@ -72,6 +71,8 @@ public:
} }
}; };
}}} //namespace } // namespace
CV__DNN_EXPERIMENTAL_NS_END
}} // namespace
#endif #endif
...@@ -43,10 +43,9 @@ ...@@ -43,10 +43,9 @@
#define OPENCV_DNN_LAYER_HPP #define OPENCV_DNN_LAYER_HPP
#include <opencv2/dnn.hpp> #include <opencv2/dnn.hpp>
namespace cv namespace cv {
{ namespace dnn {
namespace dnn CV__DNN_EXPERIMENTAL_NS_BEGIN
{
//! @addtogroup dnn //! @addtogroup dnn
//! @{ //! @{
//! //!
...@@ -80,7 +79,7 @@ private: ...@@ -80,7 +79,7 @@ private:
//! @} //! @}
//! @} //! @}
CV__DNN_EXPERIMENTAL_NS_END
} }
} }
#endif #endif
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
namespace cv { namespace cv {
namespace dnn { namespace dnn {
CV__DNN_EXPERIMENTAL_NS_BEGIN
//Useful shortcut //Useful shortcut
inline std::ostream &operator<< (std::ostream &s, cv::Range &r) inline std::ostream &operator<< (std::ostream &s, cv::Range &r)
...@@ -190,6 +191,7 @@ inline int clamp(int ax, const MatShape& shape) ...@@ -190,6 +191,7 @@ inline int clamp(int ax, const MatShape& shape)
return clamp(ax, (int)shape.size()); return clamp(ax, (int)shape.size());
} }
CV__DNN_EXPERIMENTAL_NS_END
} }
} }
#endif #endif
...@@ -40,8 +40,6 @@ ...@@ -40,8 +40,6 @@
//M*/ //M*/
#include "../precomp.hpp" #include "../precomp.hpp"
using namespace cv;
using namespace cv::dnn;
#ifdef HAVE_PROTOBUF #ifdef HAVE_PROTOBUF
#include "caffe.pb.h" #include "caffe.pb.h"
...@@ -54,7 +52,13 @@ using namespace cv::dnn; ...@@ -54,7 +52,13 @@ using namespace cv::dnn;
#include <google/protobuf/text_format.h> #include <google/protobuf/text_format.h>
#include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/io/zero_copy_stream_impl.h>
#include "caffe_io.hpp" #include "caffe_io.hpp"
#endif
namespace cv {
namespace dnn {
CV__DNN_EXPERIMENTAL_NS_BEGIN
#ifdef HAVE_PROTOBUF
using ::google::protobuf::RepeatedField; using ::google::protobuf::RepeatedField;
using ::google::protobuf::RepeatedPtrField; using ::google::protobuf::RepeatedPtrField;
using ::google::protobuf::Message; using ::google::protobuf::Message;
...@@ -361,14 +365,14 @@ public: ...@@ -361,14 +365,14 @@ public:
} }
Ptr<Importer> cv::dnn::createCaffeImporter(const String &prototxt, const String &caffeModel) Ptr<Importer> createCaffeImporter(const String &prototxt, const String &caffeModel)
{ {
return Ptr<Importer>(new CaffeImporter(prototxt.c_str(), caffeModel.c_str())); return Ptr<Importer>(new CaffeImporter(prototxt.c_str(), caffeModel.c_str()));
} }
#else //HAVE_PROTOBUF #else //HAVE_PROTOBUF
Ptr<Importer> cv::dnn::createCaffeImporter(const String&, const String&) Ptr<Importer> createCaffeImporter(const String&, const String&)
{ {
CV_Error(cv::Error::StsNotImplemented, "libprotobuf required to import data from Caffe models"); CV_Error(cv::Error::StsNotImplemented, "libprotobuf required to import data from Caffe models");
return Ptr<Importer>(); return Ptr<Importer>();
...@@ -376,7 +380,7 @@ Ptr<Importer> cv::dnn::createCaffeImporter(const String&, const String&) ...@@ -376,7 +380,7 @@ Ptr<Importer> cv::dnn::createCaffeImporter(const String&, const String&)
#endif //HAVE_PROTOBUF #endif //HAVE_PROTOBUF
Net cv::dnn::readNetFromCaffe(const String &prototxt, const String &caffeModel /*= String()*/) Net readNetFromCaffe(const String &prototxt, const String &caffeModel /*= String()*/)
{ {
Ptr<Importer> caffeImporter = createCaffeImporter(prototxt, caffeModel); Ptr<Importer> caffeImporter = createCaffeImporter(prototxt, caffeModel);
Net net; Net net;
...@@ -384,3 +388,6 @@ Net cv::dnn::readNetFromCaffe(const String &prototxt, const String &caffeModel / ...@@ -384,3 +388,6 @@ Net cv::dnn::readNetFromCaffe(const String &prototxt, const String &caffeModel /
caffeImporter->populateNet(net); caffeImporter->populateNet(net);
return net; return net;
} }
CV__DNN_EXPERIMENTAL_NS_END
}} // namespace
...@@ -50,8 +50,9 @@ ...@@ -50,8 +50,9 @@
#include <opencv2/dnn/shape_utils.hpp> #include <opencv2/dnn/shape_utils.hpp>
#include <opencv2/imgproc.hpp> #include <opencv2/imgproc.hpp>
using namespace cv; namespace cv {
using namespace cv::dnn; namespace dnn {
CV__DNN_EXPERIMENTAL_NS_BEGIN
using std::vector; using std::vector;
using std::map; using std::map;
...@@ -74,11 +75,6 @@ namespace ...@@ -74,11 +75,6 @@ namespace
}; };
} }
namespace cv
{
namespace dnn
{
template<typename T> template<typename T>
static String toString(const T &v) static String toString(const T &v)
{ {
...@@ -2126,5 +2122,5 @@ BackendWrapper::BackendWrapper(const Ptr<BackendWrapper>& base, const MatShape& ...@@ -2126,5 +2122,5 @@ BackendWrapper::BackendWrapper(const Ptr<BackendWrapper>& base, const MatShape&
BackendWrapper::~BackendWrapper() {} BackendWrapper::~BackendWrapper() {}
} CV__DNN_EXPERIMENTAL_NS_END
} }} // namespace
...@@ -42,10 +42,9 @@ ...@@ -42,10 +42,9 @@
#include "precomp.hpp" #include "precomp.hpp"
#include <opencv2/dnn/layer.details.hpp> #include <opencv2/dnn/layer.details.hpp>
namespace cv namespace cv {
{ namespace dnn {
namespace dnn CV__DNN_EXPERIMENTAL_NS_BEGIN
{
static Mutex* __initialization_mutex = NULL; static Mutex* __initialization_mutex = NULL;
Mutex& getInitializationMutex() Mutex& getInitializationMutex()
...@@ -100,4 +99,5 @@ void initializeLayerFactory() ...@@ -100,4 +99,5 @@ void initializeLayerFactory()
CV_DNN_REGISTER_LAYER_CLASS(Scale, ScaleLayer); CV_DNN_REGISTER_LAYER_CLASS(Scale, ScaleLayer);
} }
}} //namespace CV__DNN_EXPERIMENTAL_NS_END
}} // namespace
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
#include <opencv2/dnn/all_layers.hpp> #include <opencv2/dnn/all_layers.hpp>
namespace cv { namespace dnn { namespace cv { namespace dnn {
CV__DNN_EXPERIMENTAL_NS_BEGIN
Mutex& getInitializationMutex(); Mutex& getInitializationMutex();
void initializeLayerFactory(); void initializeLayerFactory();
CV__DNN_EXPERIMENTAL_NS_END
}} // namespace }} // namespace
...@@ -10,8 +10,6 @@ Implementation of Tensorflow models parser ...@@ -10,8 +10,6 @@ Implementation of Tensorflow models parser
*/ */
#include "../precomp.hpp" #include "../precomp.hpp"
using namespace cv;
using namespace cv::dnn;
#ifdef HAVE_PROTOBUF #ifdef HAVE_PROTOBUF
#include "graph.pb.h" #include "graph.pb.h"
...@@ -24,6 +22,13 @@ using namespace cv::dnn; ...@@ -24,6 +22,13 @@ using namespace cv::dnn;
#include <google/protobuf/text_format.h> #include <google/protobuf/text_format.h>
#include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/io/zero_copy_stream_impl.h>
#include "tf_io.hpp" #include "tf_io.hpp"
#endif
namespace cv {
namespace dnn {
CV__DNN_EXPERIMENTAL_NS_BEGIN
#if HAVE_PROTOBUF
using ::google::protobuf::RepeatedField; using ::google::protobuf::RepeatedField;
using ::google::protobuf::RepeatedPtrField; using ::google::protobuf::RepeatedPtrField;
...@@ -734,14 +739,14 @@ void TFImporter::populateNet(Net dstNet) ...@@ -734,14 +739,14 @@ void TFImporter::populateNet(Net dstNet)
} // namespace } // namespace
Ptr<Importer> cv::dnn::createTensorflowImporter(const String &model) Ptr<Importer> createTensorflowImporter(const String &model)
{ {
return Ptr<Importer>(new TFImporter(model.c_str())); return Ptr<Importer>(new TFImporter(model.c_str()));
} }
#else //HAVE_PROTOBUF #else //HAVE_PROTOBUF
Ptr<Importer> cv::dnn::createTensorflowImporter(const String&) Ptr<Importer> createTensorflowImporter(const String&)
{ {
CV_Error(cv::Error::StsNotImplemented, "libprotobuf required to import data from TensorFlow models"); CV_Error(cv::Error::StsNotImplemented, "libprotobuf required to import data from TensorFlow models");
return Ptr<Importer>(); return Ptr<Importer>();
...@@ -749,7 +754,7 @@ Ptr<Importer> cv::dnn::createTensorflowImporter(const String&) ...@@ -749,7 +754,7 @@ Ptr<Importer> cv::dnn::createTensorflowImporter(const String&)
#endif //HAVE_PROTOBUF #endif //HAVE_PROTOBUF
Net cv::dnn::readNetFromTensorflow(const String &model) Net readNetFromTensorflow(const String &model)
{ {
Ptr<Importer> importer = createTensorflowImporter(model); Ptr<Importer> importer = createTensorflowImporter(model);
Net net; Net net;
...@@ -757,3 +762,6 @@ Net cv::dnn::readNetFromTensorflow(const String &model) ...@@ -757,3 +762,6 @@ Net cv::dnn::readNetFromTensorflow(const String &model)
importer->populateNet(net); importer->populateNet(net);
return net; return net;
} }
CV__DNN_EXPERIMENTAL_NS_END
}} // namespace
...@@ -49,6 +49,8 @@ ...@@ -49,6 +49,8 @@
namespace cv { namespace cv {
namespace dnn { namespace dnn {
CV__DNN_EXPERIMENTAL_NS_BEGIN
#if defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER #if defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
#include "THDiskFile.h" #include "THDiskFile.h"
...@@ -1027,5 +1029,5 @@ Net readNetFromTorch(const String &model, bool isBinary) ...@@ -1027,5 +1029,5 @@ Net readNetFromTorch(const String &model, bool isBinary)
return net; return net;
} }
} CV__DNN_EXPERIMENTAL_NS_END
} }} // namespace
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment