mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-25 04:26:17 +08:00
Adding of public interfaces and refactoring of Reshape and MVN layer.
This commit is contained in:
@@ -275,8 +275,26 @@ namespace dnn
|
||||
static Ptr<InnerProductLayer> create(int axis = 1);
|
||||
};
|
||||
|
||||
class CV_EXPORTS_W MVNLayer : public Layer
|
||||
{
|
||||
public:
|
||||
double eps;
|
||||
bool normVariance, acrossChannels;
|
||||
|
||||
static Ptr<MVNLayer> create(bool normVariance = true, bool acrossChannels = false, double eps = 1e-9);
|
||||
};
|
||||
|
||||
/* Reshaping */
|
||||
|
||||
class CV_EXPORTS_W ReshapeLayer : public Layer
|
||||
{
|
||||
public:
|
||||
BlobShape newShapeDesc;
|
||||
Range newShapeRange;
|
||||
|
||||
static Ptr<ReshapeLayer> create(const BlobShape &newShape, Range applyingRange = Range::all());
|
||||
};
|
||||
|
||||
class CV_EXPORTS_W ConcatLayer : public Layer
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -115,6 +115,8 @@ namespace dnn
|
||||
|
||||
/** @brief Returns pointer to the first element of continuous size array. */
|
||||
const int *ptr() const;
|
||||
/** @overload */
|
||||
int *ptr();
|
||||
|
||||
bool equal(const BlobShape &other) const; //!< Checks equality of two shapes.
|
||||
bool operator== (const BlobShape &r) const; //!< @sa equal()
|
||||
|
||||
@@ -208,6 +208,11 @@ inline const int *BlobShape::ptr() const
|
||||
return sz;
|
||||
}
|
||||
|
||||
inline int *BlobShape::ptr()
|
||||
{
|
||||
return sz;
|
||||
}
|
||||
|
||||
inline bool BlobShape::equal(const BlobShape &other) const
|
||||
{
|
||||
if (this->dims() != other.dims())
|
||||
|
||||
@@ -57,6 +57,7 @@ inline std::ostream &operator<< (std::ostream &s, cv::Range &r)
|
||||
}
|
||||
|
||||
//Reshaping
|
||||
//TODO: add -1 specifier for automatic size inferring
|
||||
|
||||
template<typename Mat>
|
||||
void reshape(Mat &m, const BlobShape &shape)
|
||||
@@ -129,31 +130,7 @@ Mat slice(const Mat &m, const _Range &r0, const _Range &r1, const _Range &r2, co
|
||||
return m(&ranges[0]);
|
||||
}
|
||||
|
||||
//Traits for switching in ploymorphic implementations
|
||||
template<typename XMat>
|
||||
struct MatTraits
|
||||
{
|
||||
};
|
||||
|
||||
template<>
|
||||
struct MatTraits<cv::Mat>
|
||||
{
|
||||
enum
|
||||
{
|
||||
IS_MAT = 1,
|
||||
IS_UMAT = 0,
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct MatTraits<cv::UMat>
|
||||
{
|
||||
enum
|
||||
{
|
||||
IS_MAT = 0,
|
||||
IS_UMAT = 1,
|
||||
};
|
||||
};
|
||||
BlobShape computeShapeByReshapeMask(const BlobShape &srcShape, const BlobShape &maskShape, Range srcRange = Range::all());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user