lapjv.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (c) 2021 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. // The code is based on:
  15. // https://github.com/gatagat/lap/blob/master/lap/lapjv.h
  16. // Ths copyright of gatagat/lap is as follows:
  17. // MIT License
  18. #ifndef DEPLOY_PPTRACKING_CPP_INCLUDE_LAPJV_H_
  19. #define DEPLOY_PPTRACKING_CPP_INCLUDE_LAPJV_H_
  20. #define LARGE 1000000
  21. #if !defined TRUE
  22. #define TRUE 1
  23. #endif
  24. #if !defined FALSE
  25. #define FALSE 0
  26. #endif
  27. #define NEW(x, t, n) \
  28. if ((x = reinterpret_cast<t *>(malloc(sizeof(t) * (n)))) == 0) { \
  29. return -1; \
  30. }
  31. #define FREE(x) \
  32. if (x != 0) { \
  33. free(x); \
  34. x = 0; \
  35. }
  36. #define SWAP_INDICES(a, b) \
  37. { \
  38. int_t _temp_index = a; \
  39. a = b; \
  40. b = _temp_index; \
  41. }
  42. #include <opencv2/opencv.hpp>
  43. namespace PaddleDetection {
  44. typedef signed int int_t;
  45. typedef unsigned int uint_t;
  46. typedef double cost_t;
  47. typedef char boolean;
  48. typedef enum fp_t { FP_1 = 1, FP_2 = 2, FP_DYNAMIC = 3 } fp_t;
  49. int lapjv_internal(const cv::Mat &cost,
  50. const bool extend_cost,
  51. const float cost_limit,
  52. int *x,
  53. int *y);
  54. } // namespace PaddleDetection
  55. #endif // DEPLOY_PPTRACKING_CPP_INCLUDE_LAPJV_H_