提交 7b6af1da 编写于 作者: J jack

add comment on transforms.h

上级 0f30000f
...@@ -28,7 +28,10 @@ ...@@ -28,7 +28,10 @@
namespace PaddleX { namespace PaddleX {
// Object for storing all preprocessed data /*
* @brief
* This class represents object for storing all preprocessed data
* */
class ImageBlob { class ImageBlob {
public: public:
// Original image height and width // Original image height and width
...@@ -51,13 +54,28 @@ class ImageBlob { ...@@ -51,13 +54,28 @@ class ImageBlob {
} }
}; };
// Abstraction of preprocessing opration class /*
* @brief
* Abstraction of preprocessing operation class
* */
class Transform { class Transform {
public: public:
virtual void Init(const YAML::Node& item) = 0; virtual void Init(const YAML::Node& item) = 0;
/*
* @brief
* This method executes preprocessing operation on image matrix,
* result will be returned at second parameter.
* @param im: single image matrix to be preprocessed
* @param data: the raw data of single image matrix after preprocessed
* @return true if transform successfully
* */
virtual bool Run(cv::Mat* im, ImageBlob* data) = 0; virtual bool Run(cv::Mat* im, ImageBlob* data) = 0;
}; };
/*
* @brief
* This class execute normalization operation on image matrix
* */
class Normalize : public Transform { class Normalize : public Transform {
public: public:
virtual void Init(const YAML::Node& item) { virtual void Init(const YAML::Node& item) {
...@@ -72,6 +90,14 @@ class Normalize : public Transform { ...@@ -72,6 +90,14 @@ class Normalize : public Transform {
std::vector<float> std_; std::vector<float> std_;
}; };
/*
* @brief
* This class execute resize by short operation on image matrix. At first, it resizes
* the short side of image matrix to specified length. Accordingly, the long side
* will be resized in the same proportion. If new length of long side exceeds max
* size, the long size will be resized to max size, and the short size will be
* resized in the same proportion
* */
class ResizeByShort : public Transform { class ResizeByShort : public Transform {
public: public:
virtual void Init(const YAML::Node& item) { virtual void Init(const YAML::Node& item) {
...@@ -90,6 +116,12 @@ class ResizeByShort : public Transform { ...@@ -90,6 +116,12 @@ class ResizeByShort : public Transform {
int max_size_; int max_size_;
}; };
/*
* @brief
* This class execute resize by long operation on image matrix. At first, it resizes
* the long side of image matrix to specified length. Accordingly, the short side
* will be resized in the same proportion.
* */
class ResizeByLong : public Transform { class ResizeByLong : public Transform {
public: public:
virtual void Init(const YAML::Node& item) { virtual void Init(const YAML::Node& item) {
...@@ -101,6 +133,11 @@ class ResizeByLong : public Transform { ...@@ -101,6 +133,11 @@ class ResizeByLong : public Transform {
int long_size_; int long_size_;
}; };
/*
* @brief
* This class execute resize operation on image matrix. It resizes width and height
* to specified length.
* */
class Resize : public Transform { class Resize : public Transform {
public: public:
virtual void Init(const YAML::Node& item) { virtual void Init(const YAML::Node& item) {
...@@ -126,6 +163,11 @@ class Resize : public Transform { ...@@ -126,6 +163,11 @@ class Resize : public Transform {
std::string interp_; std::string interp_;
}; };
/*
* @brief
* This class execute center crop operation on image matrix. It crops the center
* of image matrix accroding to specified size.
* */
class CenterCrop : public Transform { class CenterCrop : public Transform {
public: public:
virtual void Init(const YAML::Node& item) { virtual void Init(const YAML::Node& item) {
...@@ -145,6 +187,11 @@ class CenterCrop : public Transform { ...@@ -145,6 +187,11 @@ class CenterCrop : public Transform {
int width_; int width_;
}; };
/*
* @brief
* This class execute padding operation on image matrix. It makes border on edge
* of image matrix.
* */
class Padding : public Transform { class Padding : public Transform {
public: public:
virtual void Init(const YAML::Node& item) { virtual void Init(const YAML::Node& item) {
...@@ -172,7 +219,11 @@ class Padding : public Transform { ...@@ -172,7 +219,11 @@ class Padding : public Transform {
int width_ = 0; int width_ = 0;
int height_ = 0; int height_ = 0;
}; };
/*
* @brief
* This class is transform operations manager. It stores all neccessary
* transform operations and run them in correct order.
* */
class Transforms { class Transforms {
public: public:
void Init(const YAML::Node& node, bool to_rgb = true); void Init(const YAML::Node& node, bool to_rgb = true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册