Class Perspective

Inheritance Relationships

Base Type

Class Documentation

class Perspective : public mindspore::dataset::TensorTransform

Perform perspective transform on the image.

Public Functions

Perspective(const std::vector<std::vector<int32_t>> &start_points, const std::vector<std::vector<int32_t>> &end_points, InterpolationMode interpolation)

Constructor.

参数
  • start_points[in] List containing four lists of two integers corresponding to four corners [top-left, top-right, bottom-right, bottom-left] of the original image.

  • end_points[in] List containing four lists of two integers corresponding to four corners [top-left, top-right, bottom-right, bottom-left] of the transformed image.

  • interpolation[in] An enum for the mode of interpolation. Default: InterpolationMode::kLinear.

    • InterpolationMode::kNearestNeighbour, Interpolation method is nearest-neighbor interpolation.

    • InterpolationMode::kLinear, Interpolation method is blinear interpolation.

    • InterpolationMode::kCubic, Interpolation method is bicubic interpolation.

    • InterpolationMode::kArea, Interpolation method is pixel area interpolation.

    • InterpolationMode::kCubicPil, Interpolation method is bicubic interpolation like implemented in pillow.

样例
/* Define operations */
auto decode_op = vision::Decode();
std::vector<std::vector<int32_t>> start_points = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
std::vector<std::vector<int32_t>> end_points = {{0, 2}, {2, 0}, {2, 2}, {0, 2}};
auto perspective_op = vision::Perspective(start_points, end_points, InterpolationMode::kLinear);

/* dataset is an instance of Dataset object */
dataset = dataset->Map({decode_op, perspective_op},  // operations
                       {"image"});                   // input columns
~Perspective() = default

Destructor.