doc/API/html/_image_process_8hpp_source.html
| MNN 1.0 |
ImageProcess.hpp
1 //
2 // ImageProcess.hpp
3 // MNN
4 //
5 // Created by MNN on 2018/09/19.
6 // Copyright © 2018, Alibaba Group Holding Limited
7 //
8
9 #ifndef ImageProcess_hpp
10 #define ImageProcess_hpp
11
12 #include "ErrorCode.hpp"
13 #include "Matrix.h"
14 #include "Tensor.hpp"
15
16 namespace MNN {
17 namespace CV {
18 enum ImageFormat {
25 };
26
27 enum Filter { NEAREST = 0, BILINEAR = 1, BICUBIC = 2 };
28
29 enum Wrap { CLAMP_TO_EDGE = 0, ZERO = 1, REPEAT = 2 };
30
38 class MNN_PUBLIC ImageProcess {
39 public:
40struct Inside;
43Filter filterType = NEAREST;
45ImageFormat sourceFormat = RGBA;
47ImageFormat destFormat = RGBA;
48
49// Only valid if the dest type is float
50float mean[4] = {0.0f, 0.0f, 0.0f, 0.0f};
51float normal[4] = {1.0f, 1.0f, 1.0f, 1.0f};
52
54Wrap wrap = CLAMP_TO_EDGE;
55 };
56
57 public:
64static ImageProcess* create(const Config& config, const Tensor* dstTensor = nullptr);
65
77static ImageProcess* create(const ImageFormat sourceFormat = RGBA, const ImageFormat destFormat = RGBA,
78const float* means = nullptr, const int meanCount = 0, const float* normals = nullptr,
79const int normalCount = 0, const Tensor* dstTensor = nullptr);
80
81 ~ImageProcess();
82
87inline const Matrix& matrix() const {
88return mTransform;
89 }
90void setMatrix(const Matrix& matrix);
91
101ErrorCode convert(const uint8_t* source, int iw, int ih, int stride, Tensor* dest);
102
111template <typename T>
112static Tensor* createImageTensor(int w, int h, int bpp, void* p = nullptr) {
113return createImageTensor(halide_type_of<T>(), w, h, bpp, p);
114 }
115static Tensor* createImageTensor([halide_type_t](structhalide type t.html) type, int w, int h, int bpp, void* p = nullptr);
116
117 private:
118ImageProcess(const Config& config);
119Matrix mTransform;
120Matrix mTransformInvert;
121 Inside* mInside;
122 };
123 } // namespace CV
124 } // namespace MNN
125
126 #endif /* ImageProcess_hpp */
Filter
Definition: ImageProcess.hpp:27
Definition: ImageProcess.hpp:38
Definition: ImageProcess.hpp:21
Definition: ImageProcess.hpp:22
Definition: ImageProcess.hpp:24
Definition: ImageProcess.hpp:29
Wrap
Definition: ImageProcess.hpp:29
Definition: ImageProcess.hpp:29
MNN::CV::ImageProcess::createImageTensor
static Tensor * createImageTensor(int w, int h, int bpp, void *p=nullptr)
create tensor with given data.
Definition: ImageProcess.hpp:112
Definition: ImageProcess.hpp:27
Definition: Tensor.hpp:25
Definition: ImageProcess.hpp:27
#define MNN_PUBLIC
Definition: MNNDefine.h:53
Definition: Matrix.h:48
[halide_type_t](structhalide type t.html)
Definition: HalideRuntime.h:82
Definition: AutoTime.hpp:16
Definition: ImageProcess.hpp:20
Definition: ImageProcess.hpp:41
Definition: ImageProcess.hpp:29
Definition: ImageProcess.hpp:19
Definition: ImageProcess.hpp:23
ErrorCode
Definition: ErrorCode.hpp:13
ImageFormat
Definition: ImageProcess.hpp:18
Definition: ImageProcess.hpp:27
const Matrix & matrix() const
get affine transform matrix.
Definition: ImageProcess.hpp:87