cvdefs.hpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. //
  5. // Copyright (C) 2018 Intel Corporation
  6. #ifndef OPENCV_GAPI_CV_DEFS_HPP
  7. #define OPENCV_GAPI_CV_DEFS_HPP
  8. #if defined(GAPI_STANDALONE)
  9. // Simulate OpenCV definitions taken from various
  10. // OpenCV interface headers if G-API is built in a
  11. // standalone mode.
  12. // interface.h:
  13. typedef unsigned char uchar;
  14. typedef char schar;
  15. typedef unsigned short ushort;
  16. #define CV_USRTYPE1 (void)"CV_USRTYPE1 support has been dropped in OpenCV 4.0"
  17. #define CV_CN_MAX 512
  18. #define CV_CN_SHIFT 3
  19. #define CV_DEPTH_MAX (1 << CV_CN_SHIFT)
  20. #define CV_8U 0
  21. #define CV_8S 1
  22. #define CV_16U 2
  23. #define CV_16S 3
  24. #define CV_32S 4
  25. #define CV_32F 5
  26. #define CV_64F 6
  27. #define CV_16F 7
  28. #define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1)
  29. #define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK)
  30. #define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT))
  31. #define CV_MAKE_TYPE CV_MAKETYPE
  32. #define CV_8UC1 CV_MAKETYPE(CV_8U,1)
  33. #define CV_8UC2 CV_MAKETYPE(CV_8U,2)
  34. #define CV_8UC3 CV_MAKETYPE(CV_8U,3)
  35. #define CV_8UC4 CV_MAKETYPE(CV_8U,4)
  36. #define CV_8UC(n) CV_MAKETYPE(CV_8U,(n))
  37. #define CV_8SC1 CV_MAKETYPE(CV_8S,1)
  38. #define CV_8SC2 CV_MAKETYPE(CV_8S,2)
  39. #define CV_8SC3 CV_MAKETYPE(CV_8S,3)
  40. #define CV_8SC4 CV_MAKETYPE(CV_8S,4)
  41. #define CV_8SC(n) CV_MAKETYPE(CV_8S,(n))
  42. #define CV_16UC1 CV_MAKETYPE(CV_16U,1)
  43. #define CV_16UC2 CV_MAKETYPE(CV_16U,2)
  44. #define CV_16UC3 CV_MAKETYPE(CV_16U,3)
  45. #define CV_16UC4 CV_MAKETYPE(CV_16U,4)
  46. #define CV_16UC(n) CV_MAKETYPE(CV_16U,(n))
  47. #define CV_16SC1 CV_MAKETYPE(CV_16S,1)
  48. #define CV_16SC2 CV_MAKETYPE(CV_16S,2)
  49. #define CV_16SC3 CV_MAKETYPE(CV_16S,3)
  50. #define CV_16SC4 CV_MAKETYPE(CV_16S,4)
  51. #define CV_16SC(n) CV_MAKETYPE(CV_16S,(n))
  52. #define CV_32SC1 CV_MAKETYPE(CV_32S,1)
  53. #define CV_32SC2 CV_MAKETYPE(CV_32S,2)
  54. #define CV_32SC3 CV_MAKETYPE(CV_32S,3)
  55. #define CV_32SC4 CV_MAKETYPE(CV_32S,4)
  56. #define CV_32SC(n) CV_MAKETYPE(CV_32S,(n))
  57. #define CV_16FC1 CV_MAKETYPE(CV_16F,1)
  58. #define CV_16FC2 CV_MAKETYPE(CV_16F,2)
  59. #define CV_16FC3 CV_MAKETYPE(CV_16F,3)
  60. #define CV_16FC4 CV_MAKETYPE(CV_16F,4)
  61. #define CV_16FC(n) CV_MAKETYPE(CV_16F,(n))
  62. #define CV_32FC1 CV_MAKETYPE(CV_32F,1)
  63. #define CV_32FC2 CV_MAKETYPE(CV_32F,2)
  64. #define CV_32FC3 CV_MAKETYPE(CV_32F,3)
  65. #define CV_32FC4 CV_MAKETYPE(CV_32F,4)
  66. #define CV_32FC(n) CV_MAKETYPE(CV_32F,(n))
  67. #define CV_64FC1 CV_MAKETYPE(CV_64F,1)
  68. #define CV_64FC2 CV_MAKETYPE(CV_64F,2)
  69. #define CV_64FC3 CV_MAKETYPE(CV_64F,3)
  70. #define CV_64FC4 CV_MAKETYPE(CV_64F,4)
  71. #define CV_64FC(n) CV_MAKETYPE(CV_64F,(n))
  72. // cvdef.h:
  73. #ifndef CV_ALWAYS_INLINE
  74. # if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
  75. # define CV_ALWAYS_INLINE inline __attribute__((always_inline))
  76. # elif defined(_MSC_VER)
  77. # define CV_ALWAYS_INLINE __forceinline
  78. # else
  79. # define CV_ALWAYS_INLINE inline
  80. # endif
  81. #endif
  82. #define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT)
  83. #define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1)
  84. #define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1)
  85. #define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK)
  86. #define CV_MAT_CONT_FLAG_SHIFT 14
  87. #define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT)
  88. #define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG)
  89. #define CV_IS_CONT_MAT CV_IS_MAT_CONT
  90. #define CV_SUBMAT_FLAG_SHIFT 15
  91. #define CV_SUBMAT_FLAG (1 << CV_SUBMAT_FLAG_SHIFT)
  92. #define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG)
  93. //** Size of each channel item,
  94. // 0x8442211 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */
  95. #define CV_ELEM_SIZE1(type) \
  96. ((((sizeof(size_t)<<28)|0x8442211) >> CV_MAT_DEPTH(type)*4) & 15)
  97. #define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK)
  98. /** 0x3a50 = 11 10 10 01 01 00 00 ~ array of log2(sizeof(arr_type_elem)) */
  99. #define CV_ELEM_SIZE(type) \
  100. (CV_MAT_CN(type) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> CV_MAT_DEPTH(type)*2) & 3))
  101. #ifndef CV_OVERRIDE
  102. # define CV_OVERRIDE override
  103. #endif
  104. // base.h:
  105. namespace cv
  106. {
  107. enum BorderTypes {
  108. BORDER_CONSTANT = 0, //!< `iiiiii|abcdefgh|iiiiiii` with some specified `i`
  109. BORDER_REPLICATE = 1, //!< `aaaaaa|abcdefgh|hhhhhhh`
  110. BORDER_REFLECT = 2, //!< `fedcba|abcdefgh|hgfedcb`
  111. BORDER_WRAP = 3, //!< `cdefgh|abcdefgh|abcdefg`
  112. BORDER_REFLECT_101 = 4, //!< `gfedcb|abcdefgh|gfedcba`
  113. BORDER_TRANSPARENT = 5, //!< `uvwxyz|abcdefgh|ijklmno`
  114. BORDER_REFLECT101 = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101
  115. BORDER_DEFAULT = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101
  116. BORDER_ISOLATED = 16 //!< do not look outside of ROI
  117. };
  118. // imgproc.hpp:
  119. enum InterpolationFlags{
  120. INTER_NEAREST = 0,
  121. INTER_LINEAR = 1,
  122. INTER_CUBIC = 2,
  123. INTER_AREA = 3,
  124. INTER_LANCZOS4 = 4,
  125. INTER_LINEAR_EXACT = 5,
  126. INTER_MAX = 7,
  127. };
  128. } // namespace cv
  129. static inline int cvFloor( double value )
  130. {
  131. int i = (int)value;
  132. return i - (i > value);
  133. }
  134. #endif // defined(GAPI_STANDALONE)
  135. #endif // OPENCV_GAPI_CV_DEFS_HPP