AllentDan ea54f3b2fd
Add DefaultFormatBundle (#208)
* keep DefaultFormatBundle

* add DefaultFormatBundle

* add condition

* resolve comments

* remove useless

* add override
2022-03-16 15:52:57 +08:00

48 lines
1.1 KiB
C++

// Copyright (c) OpenMMLab. All rights reserved.
#ifndef MMDEPLOY_LOAD_H
#define MMDEPLOY_LOAD_H
#include "core/mat.h"
#include "core/tensor.h"
#include "transform.h"
namespace mmdeploy {
class MMDEPLOY_API PrepareImageImpl : public TransformImpl {
public:
explicit PrepareImageImpl(const Value& args);
~PrepareImageImpl() override = default;
Result<Value> Process(const Value& input) override;
protected:
virtual Result<Tensor> ConvertToBGR(const Mat& img) = 0;
virtual Result<Tensor> ConvertToGray(const Mat& img) = 0;
protected:
struct prepare_image_arg_t {
bool to_float32{false};
std::string color_type{"color"};
};
using ArgType = struct prepare_image_arg_t;
ArgType arg_;
};
class MMDEPLOY_API PrepareImage : public Transform {
public:
explicit PrepareImage(const Value& args, int version = 0);
~PrepareImage() override = default;
Result<Value> Process(const Value& input) override { return impl_->Process(input); }
private:
std::unique_ptr<PrepareImageImpl> impl_;
};
MMDEPLOY_DECLARE_REGISTRY(PrepareImageImpl);
} // namespace mmdeploy
#endif // MMDEPLOY_LOAD_H