preprocess_op.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 <iostream>
  16. #include <vector>
  17. #include "opencv2/core.hpp"
  18. #include "opencv2/imgcodecs.hpp"
  19. #include "opencv2/imgproc.hpp"
  20. namespace PaddleOCR {
  21. class Normalize {
  22. public:
  23. virtual void Run(cv::Mat *im, const std::vector<float> &mean,
  24. const std::vector<float> &scale, const bool is_scale = true);
  25. };
  26. // RGB -> CHW
  27. class Permute {
  28. public:
  29. virtual void Run(const cv::Mat *im, float *data);
  30. };
  31. class PermuteBatch {
  32. public:
  33. virtual void Run(const std::vector<cv::Mat> imgs, float *data);
  34. };
  35. class ResizeImgType0 {
  36. public:
  37. virtual void Run(const cv::Mat &img, cv::Mat &resize_img,
  38. std::string limit_type, int limit_side_len, float &ratio_h,
  39. float &ratio_w, bool use_tensorrt);
  40. };
  41. class CrnnResizeImg {
  42. public:
  43. virtual void Run(const cv::Mat &img, cv::Mat &resize_img, float wh_ratio,
  44. bool use_tensorrt = false,
  45. const std::vector<int> &rec_image_shape = {3, 32, 320});
  46. };
  47. class ClsResizeImg {
  48. public:
  49. virtual void Run(const cv::Mat &img, cv::Mat &resize_img,
  50. bool use_tensorrt = false,
  51. const std::vector<int> &rec_image_shape = {3, 48, 192});
  52. };
  53. class TableResizeImg {
  54. public:
  55. virtual void Run(const cv::Mat &img, cv::Mat &resize_img,
  56. const int max_len = 488);
  57. };
  58. class TablePadImg {
  59. public:
  60. virtual void Run(const cv::Mat &img, cv::Mat &resize_img,
  61. const int max_len = 488);
  62. };
  63. class Resize {
  64. public:
  65. virtual void Run(const cv::Mat &img, cv::Mat &resize_img, const int h,
  66. const int w);
  67. };
  68. } // namespace PaddleOCR