You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

vision_lite.h 4.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * Copyright 2020-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. #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_VISION_LITE_H_
  17. #define MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_VISION_LITE_H_
  18. #include <map>
  19. #include <memory>
  20. #include <string>
  21. #include <utility>
  22. #include <vector>
  23. #include "include/api/status.h"
  24. #include "minddata/dataset/include/constants.h"
  25. #include "minddata/dataset/include/transforms.h"
  26. // FIXME - This internal IR header will be removed when external API classes are provided
  27. #include "minddata/dataset/kernels/ir/vision/vision_ir.h"
  28. namespace mindspore {
  29. namespace dataset {
  30. // Transform operations for performing computer vision.
  31. namespace vision {
  32. // Transform Op classes (in alphabetical order)
  33. class CenterCropOperation;
  34. class CropOperation;
  35. class DecodeOperation;
  36. class NormalizeOperation;
  37. class ResizeOperation;
  38. class RotateOperation;
  39. /// \brief Function to create a CenterCrop TensorOperation.
  40. /// \notes Crops the input image at the center to the given size.
  41. /// \param[in] size A vector representing the output size of the cropped image.
  42. /// If size is a single value, a square crop of size (size, size) is returned.
  43. /// If size has 2 values, it should be (height, width).
  44. /// \return Shared pointer to the current TensorOperation.
  45. std::shared_ptr<CenterCropOperation> CenterCrop(std::vector<int32_t> size);
  46. /// \brief Function to create a Crop TensorOp
  47. /// \notes Crop an image based on location and crop size
  48. /// \param[in] coordinates Starting location of crop. Must be a vector of two values, in the form of {x_coor, y_coor}
  49. /// \param[in] size Size of the cropped area.
  50. /// If size is a single value, a square crop of size (size, size) is returned.
  51. /// If size has 2 values, it should be (height, width).
  52. /// \return Shared pointer to the current TensorOp
  53. std::shared_ptr<CropOperation> Crop(std::vector<int32_t> coordinates, std::vector<int32_t> size);
  54. /// \brief Function to create a Decode TensorOperation.
  55. /// \notes Decode the input image in RGB mode.
  56. /// \param[in] rgb A boolean of whether to decode in RGB mode or not.
  57. /// \return Shared pointer to the current TensorOperation.
  58. std::shared_ptr<DecodeOperation> Decode(bool rgb = true);
  59. /// \brief Function to create a Normalize TensorOperation.
  60. /// \notes Normalize the input image with respect to mean and standard deviation.
  61. /// \param[in] mean A vector of mean values for each channel, w.r.t channel order.
  62. /// The mean values must be in range [0.0, 255.0].
  63. /// \param[in] std A vector of standard deviations for each channel, w.r.t. channel order.
  64. /// The standard deviation values must be in range (0.0, 255.0]
  65. /// \return Shared pointer to the current TensorOperation.
  66. std::shared_ptr<NormalizeOperation> Normalize(std::vector<float> mean, std::vector<float> std);
  67. /// \brief Function to create a Resize TensorOperation.
  68. /// \notes Resize the input image to the given size.
  69. /// \param[in] size A vector representing the output size of the resized image.
  70. /// If size is a single value, the image will be resized to this value with
  71. /// the same image aspect ratio. If size has 2 values, it should be (height, width).
  72. /// \param[in] interpolation An enum for the mode of interpolation
  73. /// \return Shared pointer to the current TensorOperation.
  74. std::shared_ptr<ResizeOperation> Resize(std::vector<int32_t> size,
  75. InterpolationMode interpolation = InterpolationMode::kLinear);
  76. /// \brief Applies an rotate transformation to an image.
  77. /// \notes Rotate the input image using a specified angle id.
  78. /// \return Shared pointer to the current TensorOperation.
  79. std::shared_ptr<RotateOperation> Rotate();
  80. } // namespace vision
  81. } // namespace dataset
  82. } // namespace mindspore
  83. #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_VISION_LITE_H_