lapjv.h 2.3 KB

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