diff --git a/modules/dnn/include/opencv2/dnn/blob.hpp b/modules/dnn/include/opencv2/dnn/blob.hpp index 72f644d8c..22c94d93f 100644 --- a/modules/dnn/include/opencv2/dnn/blob.hpp +++ b/modules/dnn/include/opencv2/dnn/blob.hpp @@ -209,6 +209,13 @@ namespace dnn */ Mat getPlane(int n, int cn); + /** @brief Returns slice of first dimension. + * @details The behaviour is similar to getPlane(), but returns all + * channels * rows * cols values, corresponding to the n-th value + * of the first dimension. + */ + Mat getPlanes(int n); + /* Shape getters of 4-dimensional blobs. */ int cols() const; //!< Returns size of the fourth axis blob. int rows() const; //!< Returns size of the thrid axis blob. diff --git a/modules/dnn/include/opencv2/dnn/blob.inl.hpp b/modules/dnn/include/opencv2/dnn/blob.inl.hpp index 6e18716f5..bd9aded85 100644 --- a/modules/dnn/include/opencv2/dnn/blob.inl.hpp +++ b/modules/dnn/include/opencv2/dnn/blob.inl.hpp @@ -391,6 +391,12 @@ inline Mat Blob::getPlane(int n, int cn) return Mat(dims() - 2, sizes() + 2, type(), ptr(n, cn)); } +inline Mat Blob::getPlanes(int n) +{ + CV_Assert(dims() > 3); + return Mat(dims() - 1, sizes() + 1, type(), ptr(n)); +} + inline int Blob::cols() const { return xsize(3); diff --git a/modules/dnn/include/opencv2/dnn/dict.hpp b/modules/dnn/include/opencv2/dnn/dict.hpp index 9bc83f5f1..d04091a14 100644 --- a/modules/dnn/include/opencv2/dnn/dict.hpp +++ b/modules/dnn/include/opencv2/dnn/dict.hpp @@ -111,7 +111,7 @@ class CV_EXPORTS Dict public: //! Checks a presence of the @p key in the dictionary. - bool has(const String &key); + bool has(const String &key) const; //! If the @p key in the dictionary then returns pointer to its value, else returns NULL. DictValue *ptr(const String &key); diff --git a/modules/dnn/include/opencv2/dnn/dnn.inl.hpp b/modules/dnn/include/opencv2/dnn/dnn.inl.hpp index 336f09d8e..a27204402 100644 --- a/modules/dnn/include/opencv2/dnn/dnn.inl.hpp +++ b/modules/dnn/include/opencv2/dnn/dnn.inl.hpp @@ -287,7 +287,7 @@ inline std::ostream &operator<<(std::ostream &stream, const DictValue &dictv) ///////////////////////////////////////////////////////////////// -inline bool Dict::has(const String &key) +inline bool Dict::has(const String &key) const { return dict.count(key) != 0; }