db_post_process.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 <math.h>
  16. #include <iostream>
  17. #include <map>
  18. #include <vector>
  19. #include "clipper.hpp"
  20. #include "opencv2/core.hpp"
  21. #include "opencv2/imgcodecs.hpp"
  22. #include "opencv2/imgproc.hpp"
  23. template <class T> T clamp(T x, T min, T max) {
  24. if (x > max)
  25. return max;
  26. if (x < min)
  27. return min;
  28. return x;
  29. }
  30. std::vector<std::vector<float>> Mat2Vector(cv::Mat mat);
  31. void GetContourArea(std::vector<std::vector<float>> box, float unclip_ratio,
  32. float &distance);
  33. cv::RotatedRect Unclip(std::vector<std::vector<float>> box, float unclip_ratio);
  34. std::vector<std::vector<float>> Mat2Vector(cv::Mat mat);
  35. bool XsortFp32(std::vector<float> a, std::vector<float> b);
  36. bool XsortInt(std::vector<int> a, std::vector<int> b);
  37. std::vector<std::vector<int>>
  38. OrderPointsClockwise(std::vector<std::vector<int>> pts);
  39. std::vector<std::vector<float>> GetMiniBoxes(cv::RotatedRect box, float &ssid);
  40. float BoxScoreFast(std::vector<std::vector<float>> box_array, cv::Mat pred);
  41. std::vector<std::vector<std::vector<int>>>
  42. BoxesFromBitmap(const cv::Mat pred, const cv::Mat bitmap,
  43. std::map<std::string, double> Config);
  44. std::vector<std::vector<std::vector<int>>>
  45. FilterTagDetRes(std::vector<std::vector<std::vector<int>>> boxes, float ratio_h,
  46. float ratio_w, cv::Mat srcimg);