ocr_utils.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #pragma once
  15. #include "ultra_infer/core/fd_tensor.h"
  16. #include "ultra_infer/utils/utils.h"
  17. #include "ultra_infer/vision/common/result.h"
  18. #include <set>
  19. #include <vector>
  20. #include "opencv2/core.hpp"
  21. #include "opencv2/imgproc.hpp"
  22. namespace ultra_infer {
  23. namespace vision {
  24. namespace ocr {
  25. ULTRAINFER_DECL cv::Mat GetRotateCropImage(const cv::Mat &srcimage,
  26. const std::array<int, 8> &box);
  27. ULTRAINFER_DECL void SortBoxes(std::vector<std::array<int, 8>> *boxes);
  28. ULTRAINFER_DECL std::vector<int> ArgSort(const std::vector<float> &array);
  29. ULTRAINFER_DECL std::vector<float> Softmax(std::vector<float> &src);
  30. ULTRAINFER_DECL std::vector<int> Xyxyxyxy2Xyxy(std::array<int, 8> &box);
  31. ULTRAINFER_DECL float Dis(std::vector<int> &box1, std::vector<int> &box2);
  32. ULTRAINFER_DECL float Iou(std::vector<int> &box1, std::vector<int> &box2);
  33. ULTRAINFER_DECL bool ComparisonDis(const std::vector<float> &dis1,
  34. const std::vector<float> &dis2);
  35. } // namespace ocr
  36. } // namespace vision
  37. } // namespace ultra_infer