diff --git a/modules/dnn/include/opencv2/dnn/dnn.hpp b/modules/dnn/include/opencv2/dnn/dnn.hpp index 3ee75cb28..16cacb85e 100644 --- a/modules/dnn/include/opencv2/dnn/dnn.hpp +++ b/modules/dnn/include/opencv2/dnn/dnn.hpp @@ -49,13 +49,14 @@ namespace dnn ~Net(); int addLayer(const String &name, const String &type, LayerParams ¶ms); - int getLayerId(LayerId layer); - void deleteLayer(LayerId layer); + int addLayerToPrev(const String &name, const String &type, LayerParams ¶ms); - void setNetInputs(const std::vector &inputBlobNames); + int getLayerId(const String &layer); + void deleteLayer(LayerId layer); void connect(String outPin, String inpPin); void connect(int outLayerId, int outNum, int inLayerId, int inNum); + void setNetInputs(const std::vector &inputBlobNames); void forward(); void forward(LayerId toLayer); diff --git a/modules/dnn/src/dnn.cpp b/modules/dnn/src/dnn.cpp index 472455a8c..714643a50 100644 --- a/modules/dnn/src/dnn.cpp +++ b/modules/dnn/src/dnn.cpp @@ -383,7 +383,7 @@ int Net::addLayer(const String &name, const String &type, LayerParams ¶ms) { if (name.find('.') != String::npos) { - CV_Error(Error::StsBadArg, "Added layer name \"" + name + "\" should not contain dot symbol"); + CV_Error(Error::StsBadArg, "Added layer name \"" + name + "\" must not contain dot symbol"); return -1; } @@ -400,6 +400,14 @@ int Net::addLayer(const String &name, const String &type, LayerParams ¶ms) return id; } +int Net::addLayerToPrev(const String &name, const String &type, LayerParams ¶ms) +{ + int prvLid = impl->lastLayerId; + int newLid = this->addLayer(name, type, params); + this->connect(prvLid, 0, newLid, 0); + return newLid; +} + void Net::connect(int outLayerId, int outNum, int inLayerId, int inNum) { impl->connect(outLayerId, outNum, inLayerId, inNum); @@ -467,6 +475,18 @@ Blob Net::getParam(LayerId layer, int numParam) return layerBlobs[numParam]; } +int Net::getLayerId(const String &layer) +{ + return impl->getLayerId(layer); +} + +void Net::deleteLayer(LayerId) +{ + CV_Error(Error::StsNotImplemented, ""); +} + +////////////////////////////////////////////////////////////////////////// + Importer::~Importer() { @@ -530,16 +550,5 @@ Ptr LayerRegister::createLayerInstance(const String &_type, LayerParams& } } -int Net::getLayerId(LayerId) -{ - CV_Error(Error::StsNotImplemented, ""); - return -1; -} - -void Net::deleteLayer(LayerId) -{ - CV_Error(Error::StsNotImplemented, ""); -} - } } diff --git a/modules/dnn/src/layers/im2col.cpp b/modules/dnn/src/layers/im2col.cpp index 6a400bd9c..a4a7ceca8 100644 --- a/modules/dnn/src/layers/im2col.cpp +++ b/modules/dnn/src/layers/im2col.cpp @@ -9,10 +9,10 @@ namespace dnn { void im2col_ocl(UMat &img, - int channels, int height, int width, + int channels, int height, int width, int kernel_h, int kernel_w, int pad_h, int pad_w, - int stride_h, int stride_w, + int stride_h, int stride_w, UMat &col) { int h_out = (height + 2 * pad_h - kernel_h) / stride_h + 1; diff --git a/modules/dnn/src/layers/im2col.hpp b/modules/dnn/src/layers/im2col.hpp index b82ef706e..93d09a757 100644 --- a/modules/dnn/src/layers/im2col.hpp +++ b/modules/dnn/src/layers/im2col.hpp @@ -7,8 +7,8 @@ namespace dnn { template -void im2col_cpu(const Dtype* data_im, - int channels, int height, int width, +void im2col_cpu(const Dtype* data_im, + int channels, int height, int width, int kernel_h, int kernel_w, int pad_h, int pad_w, int stride_h, int stride_w, @@ -36,7 +36,7 @@ void im2col_cpu(const Dtype* data_im, } template -void col2im_cpu(const Dtype* data_col, +void col2im_cpu(const Dtype* data_col, int channels, int height, int width, int patch_h, int patch_w, int pad_h, int pad_w,