FastDeploy  latest
Fast & Easy to Deploy!
ppocr_v3.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 
17 #include "fastdeploy/vision/ocr/ppocr/ppocr_v2.h"
18 
19 namespace fastdeploy {
23 namespace pipeline {
26 class FASTDEPLOY_DECL PPOCRv3 : public PPOCRv2 {
27  public:
37  : PPOCRv2(det_model, cls_model, rec_model) {
38  // The only difference between v2 and v3
39  auto preprocess_shape = recognizer_->GetPreprocessor().GetRecImageShape();
40  preprocess_shape[1] = 48;
41  recognizer_->GetPreprocessor().SetRecImageShape(preprocess_shape);
42  }
50  : PPOCRv2(det_model, rec_model) {
51  // The only difference between v2 and v3
52  auto preprocess_shape = recognizer_->GetPreprocessor().GetRecImageShape();
53  preprocess_shape[1] = 48;
54  recognizer_->GetPreprocessor().SetRecImageShape(preprocess_shape);
55  }
56 
61  std::unique_ptr<PPOCRv3> Clone() const {
62  std::unique_ptr<PPOCRv3> clone_model = utils::make_unique<PPOCRv3>(PPOCRv3(*this));
63  clone_model->detector_ = detector_->Clone().release();
64  if (classifier_ != nullptr) {
65  clone_model->classifier_ = classifier_->Clone().release();
66  }
67  clone_model->recognizer_ = recognizer_->Clone().release();
68  return clone_model;
69  }
70 };
71 
72 } // namespace pipeline
73 
74 namespace application {
75 namespace ocrsystem {
76  typedef pipeline::PPOCRv3 PPOCRSystemv3;
77 } // namespace ocrsystem
78 } // namespace application
79 
80 } // namespace fastdeploy
DBDetector object is used to load the detection model provided by PaddleOCR.
Definition: dbdetector.h:33
Classifier object is used to load the classification model provided by PaddleOCR. ...
Definition: classifier.h:32
PPOCRv3 is used to load PP-OCRv3 series models provided by PaddleOCR.
Definition: ppocr_v3.h:26
std::unique_ptr< PPOCRv3 > Clone() const
Clone a new PPOCRv3 with less memory usage when multiple instances of the same model are created...
Definition: ppocr_v3.h:61
PPOCRv3(fastdeploy::vision::ocr::DBDetector *det_model, fastdeploy::vision::ocr::Classifier *cls_model, fastdeploy::vision::ocr::Recognizer *rec_model)
Set up the detection model path, classification model path and recognition model path respectively...
Definition: ppocr_v3.h:34
PPOCRv3(fastdeploy::vision::ocr::DBDetector *det_model, fastdeploy::vision::ocr::Recognizer *rec_model)
Classification model is optional, so this function is set up the detection model path and recognition...
Definition: ppocr_v3.h:48
Recognizer object is used to load the recognition model provided by PaddleOCR.
Definition: recognizer.h:32
All C++ FastDeploy APIs are defined inside this namespace.
Definition: option.h:16
PPOCRv2 is used to load PP-OCRv2 series models provided by PaddleOCR.
Definition: ppocr_v2.h:36