paddleocr.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (c) 2020 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. #pragma once
  15. #include <include/ocr_cls.h>
  16. #include <include/ocr_det.h>
  17. #include <include/ocr_rec.h>
  18. namespace PaddleOCR {
  19. class PPOCR {
  20. public:
  21. explicit PPOCR();
  22. ~PPOCR();
  23. std::vector<std::vector<OCRPredictResult>> ocr(std::vector<cv::Mat> img_list,
  24. bool det = true,
  25. bool rec = true,
  26. bool cls = true);
  27. std::vector<OCRPredictResult> ocr(cv::Mat img, bool det = true,
  28. bool rec = true, bool cls = true);
  29. void reset_timer();
  30. void benchmark_log(int img_num);
  31. protected:
  32. std::vector<double> time_info_det = {0, 0, 0};
  33. std::vector<double> time_info_rec = {0, 0, 0};
  34. std::vector<double> time_info_cls = {0, 0, 0};
  35. void det(cv::Mat img, std::vector<OCRPredictResult> &ocr_results);
  36. void rec(std::vector<cv::Mat> img_list,
  37. std::vector<OCRPredictResult> &ocr_results);
  38. void cls(std::vector<cv::Mat> img_list,
  39. std::vector<OCRPredictResult> &ocr_results);
  40. private:
  41. DBDetector *detector_ = nullptr;
  42. Classifier *classifier_ = nullptr;
  43. CRNNRecognizer *recognizer_ = nullptr;
  44. };
  45. } // namespace PaddleOCR