ImageProcess.hpp
浏览该文件的文档.
//
// ImageProcess.hpp
// MNN
//
// Created by MNN on 2018/09/19.
// Copyright © 2018, Alibaba Group Holding Limited
//
#ifndef ImageProcess_hpp
#define ImageProcess_hpp
#include "ErrorCode.hpp"
#include "Matrix.h"
#include "Tensor.hpp"
namespace MNN {
namespace CV {
enum ImageFormat {
RGBA = 0,
RGB,
BGR,
GRAY,
BGRA,
YUV_NV21 = 11,
};
enum Filter { NEAREST = 0, BILINEAR = 1, BICUBIC = 2 };
enum Wrap { CLAMP_TO_EDGE = 0, ZERO = 1, REPEAT = 2 };
class MNN_PUBLIC ImageProcess {
public:
struct Inside;
struct Config {
Filter filterType = NEAREST;
ImageFormat sourceFormat = RGBA;
ImageFormat destFormat = RGBA;
// Only valid if the dest type is float
float mean[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float normal[4] = {1.0f, 1.0f, 1.0f, 1.0f};
Wrap wrap = CLAMP_TO_EDGE;
};
public:
static ImageProcess* create(const Config& config, const Tensor* dstTensor = nullptr);
static ImageProcess* create(const ImageFormat sourceFormat = RGBA, const ImageFormat destFormat = RGBA,
const float* means = nullptr, const int meanCount = 0, const float* normals = nullptr,
const int normalCount = 0, const Tensor* dstTensor = nullptr);
~ImageProcess();
inline const Matrix& matrix() const {
return mTransform;
}
void setMatrix(const Matrix& matrix);
ErrorCode convert(const uint8_t* source, int iw, int ih, int stride, Tensor* dest);
template <typename T>
static Tensor* createImageTensor(int w, int h, int bpp, void* p = nullptr) {
return createImageTensor(halide_type_of<T>(), w, h, bpp, p);
}
static Tensor* createImageTensor(halide_type_t type, int w, int h, int bpp, void* p = nullptr);
private:
ImageProcess(const Config& config);
Matrix mTransform;
Matrix mTransformInvert;
Inside* mInside;
};
} // namespace CV
} // namespace MNN
#endif /* ImageProcess_hpp */
MNN::CV::Filter
Filter
Definition: ImageProcess.hpp:27
MNN::CV::ImageProcess
Definition: ImageProcess.hpp:38
MNN::CV::BGR
Definition: ImageProcess.hpp:21
MNN::CV::GRAY
Definition: ImageProcess.hpp:22
ErrorCode.hpp
MNN::CV::YUV_NV21
Definition: ImageProcess.hpp:24
Matrix.h
MNN::CV::CLAMP_TO_EDGE
Definition: ImageProcess.hpp:29
MNN::CV::Wrap
Wrap
Definition: ImageProcess.hpp:29
MNN::CV::REPEAT
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
MNN::CV::NEAREST
Definition: ImageProcess.hpp:27
MNN::Tensor
Definition: Tensor.hpp:25
MNN::CV::BILINEAR
Definition: ImageProcess.hpp:27
MNN_PUBLIC
#define MNN_PUBLIC
Definition: MNNDefine.h:53
MNN::CV::Matrix
Definition: Matrix.h:48
halide_type_t
Definition: HalideRuntime.h:82
MNN
Definition: AutoTime.hpp:16
MNN::CV::RGB
Definition: ImageProcess.hpp:20
MNN::CV::ImageProcess::Config
Definition: ImageProcess.hpp:41
MNN::CV::ZERO
Definition: ImageProcess.hpp:29
Tensor.hpp
MNN::CV::RGBA
Definition: ImageProcess.hpp:19
MNN::CV::BGRA
Definition: ImageProcess.hpp:23
MNN::ErrorCode
ErrorCode
Definition: ErrorCode.hpp:13
MNN::CV::ImageFormat
ImageFormat
Definition: ImageProcess.hpp:18
MNN::CV::BICUBIC
Definition: ImageProcess.hpp:27
MNN::CV::ImageProcess::matrix
const Matrix & matrix() const
get affine transform matrix.
Definition: ImageProcess.hpp:87