diff --git a/deploy/cpp/include/paddlex/transforms.h b/deploy/cpp/include/paddlex/transforms.h index 43ecd0352d2474aed9f8ffa45dc6d4ce6f93d651..66e9839a92c406c30139eec8ef96a877ddcaaa83 100644 --- a/deploy/cpp/include/paddlex/transforms.h +++ b/deploy/cpp/include/paddlex/transforms.h @@ -28,7 +28,10 @@ namespace PaddleX { -// Object for storing all preprocessed data +/* + * @brief + * This class represents object for storing all preprocessed data + * */ class ImageBlob { public: // Original image height and width @@ -51,13 +54,28 @@ class ImageBlob { } }; -// Abstraction of preprocessing opration class +/* + * @brief + * Abstraction of preprocessing operation class + * */ class Transform { public: 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; }; +/* + * @brief + * This class execute normalization operation on image matrix + * */ class Normalize : public Transform { public: virtual void Init(const YAML::Node& item) { @@ -72,6 +90,14 @@ class Normalize : public Transform { std::vector 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 { public: virtual void Init(const YAML::Node& item) { @@ -90,6 +116,12 @@ class ResizeByShort : public Transform { 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 { public: virtual void Init(const YAML::Node& item) { @@ -101,6 +133,11 @@ class ResizeByLong : public Transform { int long_size_; }; +/* + * @brief + * This class execute resize operation on image matrix. It resizes width and height + * to specified length. + * */ class Resize : public Transform { public: virtual void Init(const YAML::Node& item) { @@ -126,6 +163,11 @@ class Resize : public Transform { 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 { public: virtual void Init(const YAML::Node& item) { @@ -145,6 +187,11 @@ class CenterCrop : public Transform { int width_; }; +/* + * @brief + * This class execute padding operation on image matrix. It makes border on edge + * of image matrix. + * */ class Padding : public Transform { public: virtual void Init(const YAML::Node& item) { @@ -172,7 +219,11 @@ class Padding : public Transform { int width_ = 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 { public: void Init(const YAML::Node& node, bool to_rgb = true);