• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2021 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_DATASET_VISION_ASCEND_H_
18 #define MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_DATASET_VISION_ASCEND_H_
19 
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <utility>
24 #include <vector>
25 #include "include/api/status.h"
26 #include "include/dataset/constants.h"
27 #include "include/dataset/transforms.h"
28 
29 namespace mindspore {
30 namespace dataset {
31 
32 // Transform operations for performing computer vision.
33 namespace vision {
34 
35 /* ##################################### API class ###########################################*/
36 
37 /// \brief Decode and resize JPEG image using the hardware algorithm of
38 ///     Ascend series chip DVPP module.
39 class DvppDecodeResizeJpeg final : public TensorTransform {
40  public:
41   /// \brief Constructor.
42   /// \param[in] resize Parameter vector of two integers for each dimension, with respect to H,W order.
43   explicit DvppDecodeResizeJpeg(std::vector<uint32_t> resize);
44 
45   /// \brief Destructor.
46   ~DvppDecodeResizeJpeg() = default;
47 
48  protected:
49   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
50   /// \return Shared pointer to TensorOperation object.
51   std::shared_ptr<TensorOperation> Parse() override;
52 
53   std::shared_ptr<TensorOperation> Parse(const MapTargetDevice &env) override;
54 
55  private:
56   struct Data;
57   std::shared_ptr<Data> data_;
58 };
59 
60 /// \brief Decode, resize and crop JPEG image using the hardware algorithm of
61 ///     Ascend series chip DVPP module.
62 class DvppDecodeResizeCropJpeg final : public TensorTransform {
63  public:
64   /// \brief Constructor.
65   /// \param[in] crop Parameter vector of two integers for each dimension after final crop, with respect to H,W order.
66   /// \param[in] resize Parameter vector of two integers for each dimension after resize, with respect to H,W order.
67   DvppDecodeResizeCropJpeg(std::vector<uint32_t> crop, std::vector<uint32_t> resize);
68 
69   /// \brief Destructor.
70   ~DvppDecodeResizeCropJpeg() = default;
71 
72  protected:
73   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
74   /// \return Shared pointer to TensorOperation object.
75   std::shared_ptr<TensorOperation> Parse() override;
76 
77   std::shared_ptr<TensorOperation> Parse(const MapTargetDevice &env) override;
78 
79  private:
80   struct Data;
81   std::shared_ptr<Data> data_;
82 };
83 
84 /// \brief Decode PNG image using the hardware algorithm of
85 ///     Ascend series chip DVPP module.
86 class DvppDecodePng final : public TensorTransform {
87  public:
88   /// \brief Constructor.
89   DvppDecodePng();
90 
91   /// \brief Destructor.
92   ~DvppDecodePng() = default;
93 
94  protected:
95   /// \brief The function to convert a TensorTransform object into a TensorOperation object.
96   /// \return Shared pointer to TensorOperation object.
97   std::shared_ptr<TensorOperation> Parse() override;
98 
99   std::shared_ptr<TensorOperation> Parse(const MapTargetDevice &env) override;
100 };
101 
102 }  // namespace vision
103 }  // namespace dataset
104 }  // namespace mindspore
105 
106 #endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_DATASET_VISION_ASCEND_H_
107