FastDeploy  latest
Fast & Easy to Deploy!
preprocessor.h
1 // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 #include "fastdeploy/vision/common/processors/manager.h"
17 #include "fastdeploy/vision/common/processors/transform.h"
18 #include "fastdeploy/vision/common/result.h"
19 
20 namespace fastdeploy {
21 namespace vision {
22 
23 namespace detection {
26 class FASTDEPLOY_DECL PaddleDetPreprocessor : public ProcessorManager {
27  public:
28  PaddleDetPreprocessor() = default;
33  explicit PaddleDetPreprocessor(const std::string& config_file);
34 
43  virtual bool Apply(FDMatBatch* image_batch,
44  std::vector<FDTensor>* outputs);
45 
47  void DisableNormalize();
49  void DisablePermute();
50 
51  std::string GetArch() {
52  return arch_;
53  }
54 
55  private:
56  bool BuildPreprocessPipelineFromConfig();
57  std::vector<std::shared_ptr<Processor>> processors_;
58  std::shared_ptr<PadToSize> pad_op_ =
59  std::make_shared<PadToSize>(0, 0, std::vector<float>(3, 0));
60  bool initialized_ = false;
61  // for recording the switch of hwc2chw
62  bool disable_permute_ = false;
63  // for recording the switch of normalize
64  bool disable_normalize_ = false;
65  // read config file
66  std::string config_file_;
67  // read arch_ for postprocess
68  std::string arch_;
69 };
70 
71 } // namespace detection
72 } // namespace vision
73 } // namespace fastdeploy
FDMatBatch contains batch data for preprocess.
Definition: mat_batch.h:28
Preprocessor object for PaddleDet serials model.
Definition: preprocessor.h:26
ProcessorManager for Preprocess.
Definition: manager.h:27
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16