ax_ives_api.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /**********************************************************************************
  2. *
  3. * Copyright (c) 2019-2022 Beijing AXera Technology Co., Ltd. All Rights Reserved.
  4. *
  5. * This source file is the property of Beijing AXera Technology Co., Ltd. and
  6. * may not be copied or distributed in any isomorphic form without the prior
  7. * written consent of Beijing AXera Technology Co., Ltd.
  8. *
  9. **********************************************************************************/
  10. #ifndef _AX_IVES_AP_H_80DEC0DA_BDEB_419F_85AD_3371389435C3_
  11. #define _AX_IVES_AP_H_80DEC0DA_BDEB_419F_85AD_3371389435C3_
  12. #include "ax_global_type.h"
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #define AX_IVES_MAX_IMAGE_WIDTH (4096)
  17. #define AX_IVES_MAX_IMAGE_HEIGHT (3072)
  18. #define AX_IVES_MAX_REGION_NUM (254)
  19. typedef enum {
  20. IVES_CCL_MODE_4C = 0x0, /* 4-connectivity */
  21. IVES_CCL_MODE_8C = 0x1, /* 8-connectivity */
  22. IVES_CCL_MODE_BUTT
  23. } AX_IVES_CCL_MODE_E;
  24. typedef struct axIVES_RECT_S {
  25. AX_U32 u32X;
  26. AX_U32 u32Y;
  27. AX_U32 u32W;
  28. AX_U32 u32H;
  29. } AX_IVES_RECT_S;
  30. typedef struct axIVES_MB_SIZE_S {
  31. AX_U32 u32W; /* x pixels */
  32. AX_U32 u32H; /* y pixels */
  33. } AX_IVES_MB_SIZE_S;
  34. typedef struct axIVES_BLK_SIZE_S {
  35. AX_U32 u32W;
  36. AX_U32 u32H;
  37. } AX_IVES_BLK_SIZE_S;
  38. typedef struct axIVES_REGION_S {
  39. AX_U32 u32Area; /* Represented by the pixel number */
  40. AX_U16 u16Left; /* Circumscribed rectangle left border */
  41. AX_U16 u16Top; /* Circumscribed rectangle top border */
  42. AX_U16 u16Right; /* Circumscribed rectangle right border */
  43. AX_U16 u16Bottom; /* Circumscribed rectangle bottom border */
  44. } AX_IVES_REGION_S;
  45. typedef struct axIVES_CCBLOB_S {
  46. AX_IVES_CCL_MODE_E enMode; /* [IN ]: CCL mode */
  47. AX_U32 u32AreaThrs; /* [IN ]: threshold of area pixels */
  48. AX_U32 u32RegionNum; /* [OUT]: Number of valid region */
  49. AX_IVES_REGION_S arrRegion[AX_IVES_MAX_REGION_NUM]; /* [OUT]: Valid regions with 'u32Area>0' */
  50. } AX_IVES_CCBLOB_S;
  51. typedef AX_VIDEO_FRAME_S AX_IVES_IMAGE_S;
  52. //////////////////////////////////////////////////////////////////////////////////////
  53. /// @brief Initialize or uninitialize IVES device
  54. ///
  55. /// @param N/A
  56. ///
  57. /// @return 0 if success, otherwise failure
  58. //////////////////////////////////////////////////////////////////////////////////////
  59. AX_S32 AX_IVES_Init(AX_VOID);
  60. AX_S32 AX_IVES_DeInit(AX_VOID);
  61. //////////////////////////////////////////////////////////////////////////////////////
  62. /// MD
  63. //////////////////////////////////////////////////////////////////////////////////////
  64. typedef AX_S32 MD_CHN;
  65. typedef enum axMD_ALG_MODE_E { AX_MD_MODE_REF = 0x0, AX_MD_MODE_BUTT } AX_MD_ALG_MODE_E;
  66. typedef struct axMD_CHN_ATTR_S {
  67. MD_CHN mdChn;
  68. AX_MD_ALG_MODE_E enAlgMode;
  69. AX_IVES_MB_SIZE_S stMbSize;
  70. AX_IVES_RECT_S stArea;
  71. AX_U8 u8ThrY; /* threshold of Y */
  72. } AX_MD_CHN_ATTR_S;
  73. typedef struct axMD_MB_THR_S {
  74. AX_U32 u32Count; /* MB count */
  75. AX_U8 *pMbThrs; /* 1 or 0 thresold of each MB */
  76. } AX_MD_MB_THR_S;
  77. //////////////////////////////////////////////////////////////////////////////////////
  78. /// @brief Initialize or uninitialize MD module
  79. ///
  80. /// @param NA
  81. ///
  82. /// @return 0 if success, otherwise failure
  83. //////////////////////////////////////////////////////////////////////////////////////
  84. AX_S32 AX_IVES_MD_Init(AX_VOID);
  85. AX_S32 AX_IVES_MD_DeInit(AX_VOID);
  86. //////////////////////////////////////////////////////////////////////////////////////
  87. /// @brief Create or destory MD channel
  88. ///
  89. /// @param mdChn [I]: specifies the MD channel to create
  90. /// @param pstAttr [I]: specifies channel attribute.
  91. ///
  92. /// @return 0 if success, otherwise failure
  93. //////////////////////////////////////////////////////////////////////////////////////
  94. AX_S32 AX_IVES_MD_CreateChn(MD_CHN mdChn, AX_MD_CHN_ATTR_S *pstAttr);
  95. AX_S32 AX_IVES_MD_DestoryChn(MD_CHN mdChn);
  96. //////////////////////////////////////////////////////////////////////////////////////
  97. /// @brief Set or get channel attribute
  98. ///
  99. /// @param mdChn [I ]: specifies the MD channel created.
  100. /// @param pstAttr [IO]: specifies the channel attribute to set [I] or get [O].
  101. /// <NOTE>
  102. /// - enAlgMode: static parameter, cannot be changed.
  103. /// - stMbSize : static parameter, cannot be changed.
  104. /// - stMbSize : static parameter, cannot be changed.
  105. /// - stArea : static parameter, cannot be changed.
  106. ///
  107. /// @return 0 if success, otherwise failure
  108. /// If static parametes are changed, AX_ERR_ILLEGAL_PARAM error will be returned.
  109. //////////////////////////////////////////////////////////////////////////////////////
  110. AX_S32 AX_IVES_MD_SetChnAttr(MD_CHN mdChn, AX_MD_CHN_ATTR_S *pstAttr);
  111. AX_S32 AX_IVES_MD_GetChnAttr(MD_CHN mdChn, AX_MD_CHN_ATTR_S *pstAttr);
  112. //////////////////////////////////////////////////////////////////////////////////////
  113. /// @brief Process image
  114. /// The 1st input image is reference image, mb thresholds will return all 0.
  115. ///
  116. /// @param mdChn [I]: specifies the MD channel created.
  117. /// @param pstCur [I]: specifies the image to process
  118. /// @param pstMbThr [O]: return the detected result.
  119. ///
  120. /// @return 0 if success, otherwise failure
  121. //////////////////////////////////////////////////////////////////////////////////////
  122. AX_S32 AX_IVES_MD_Process(MD_CHN mdChn, AX_IVES_IMAGE_S *pstCur, AX_MD_MB_THR_S *pstMbThr);
  123. AX_S32 AX_IVES_MD_ProcessV2(MD_CHN mdChn, AX_IVES_IMAGE_S *pstCur, AX_MD_MB_THR_S *pstMbThr, AX_IVES_CCBLOB_S *pstBlob);
  124. //////////////////////////////////////////////////////////////////////////////////////
  125. /// MD
  126. //////////////////////////////////////////////////////////////////////////////////////
  127. typedef AX_S32 OD_CHN;
  128. //////////////////////////////////////////////////////////////////////////////////////
  129. /// @brief Initialize or uninitialize OD module
  130. ///
  131. /// @param NA
  132. ///
  133. /// @return 0 if success, otherwise failure
  134. //////////////////////////////////////////////////////////////////////////////////////
  135. AX_S32 AX_IVES_OD_Init(AX_VOID);
  136. AX_S32 AX_IVES_OD_DeInit(AX_VOID);
  137. //////////////////////////////////////////////////////////////////////////////////////
  138. /// @brief Create or destory OD channel
  139. ///
  140. /// @param odChn [I]: specifies the OD channel
  141. /// @param pstAttr [I]: specifies the channel attribute.
  142. ///
  143. /// @return 0 if success, otherwise failure
  144. //////////////////////////////////////////////////////////////////////////////////////
  145. typedef struct axOD_CHN_ATTR_S {
  146. OD_CHN odChn;
  147. AX_IVES_RECT_S stArea; /* area of OD */
  148. AX_U32 u32FrameRate; /* frame rate: 25/30/60 */
  149. AX_U8 u8ThrdY; /* threshold of Y, range [0 - 255] */
  150. AX_U8 u8ConfidenceY; /* threshold confidence percent, range [0 - 100] */
  151. /*
  152. @param u32LuxThrd: specifies the lux threshold. U22.10
  153. - u32LuxThrd >= 1024, means if current lux < u32LuxThrd, mark od = 1
  154. - u32LuxThrd = 0, skip the beginning 3 seconds frames to estimate the scene lux.
  155. @param u32LuxDiff: specifies the lux changed threshold.
  156. - if u32LuxThrd >= 1024, u32LuxDiff is the absolute changed lux threshold, U22.10
  157. it means:
  158. if abs(current lux - last lux) > u32LuxDiff, then mark od = 1
  159. - if u32LuxThrd = 0, u32LuxDiff is the confidence of lux changed, range [0 - 100]
  160. it means:
  161. if (current lux < scene lux * u32LuxDiff/100.0), then mark od = 1
  162. Recommended to set:
  163. when lux is descended to 40% of scense lux, then mark od = 1
  164. u32LuxThrd = 0 // use scene lux to reference lux
  165. u32LuxDiff = 60 // lux descend confidenece is 40%
  166. */
  167. AX_U32 u32LuxThrd;
  168. AX_U32 u32LuxDiff;
  169. } AX_OD_CHN_ATTR_S;
  170. AX_S32 AX_IVES_OD_CreateChn(OD_CHN odChn, AX_OD_CHN_ATTR_S *pstAttr);
  171. AX_S32 AX_IVES_OD_DestoryChn(OD_CHN odChn);
  172. //////////////////////////////////////////////////////////////////////////////////////
  173. /// @brief Set or get channel attribute
  174. ///
  175. /// @param odChn [I ]: specifies the OD channel created.
  176. /// @param pstAttr [IO]: specifies the channel attribute to set [I] or get [O]
  177. ///
  178. /// @return 0 if success, otherwise failure
  179. /// If static parametes are changed, AX_ERR_ILLEGAL_PARAM error will be returned.
  180. //////////////////////////////////////////////////////////////////////////////////////
  181. AX_S32 AX_IVES_OD_SetChnAttr(OD_CHN odChn, AX_OD_CHN_ATTR_S *pstAttr);
  182. AX_S32 AX_IVES_OD_GetChnAttr(OD_CHN odChn, AX_OD_CHN_ATTR_S *pstAttr);
  183. //////////////////////////////////////////////////////////////////////////////////////
  184. /// @brief Process image
  185. ///
  186. /// @param odChn [I]: specifies the OD channel created.
  187. /// @param pstCur [I]: specifies the image to process
  188. /// @param pResult [O]: return the detection result, 0: not occlusion, 1: occlusion
  189. ///
  190. /// @return 0 if success, otherwise failure
  191. //////////////////////////////////////////////////////////////////////////////////////
  192. typedef struct axIVES_OD_IMAGE_S {
  193. AX_IVES_IMAGE_S *pstImg;
  194. AX_U32 u32Lux; /* current lux returned by AE, U22.10 */
  195. } AX_IVES_OD_IMAGE_S;
  196. AX_S32 AX_IVES_OD_Process(OD_CHN odChn, const AX_IVES_OD_IMAGE_S *pstCur, AX_U8 *pResult);
  197. //////////////////////////////////////////////////////////////////////////////////////
  198. /// SCD (Scene Change Detection)
  199. //////////////////////////////////////////////////////////////////////////////////////
  200. typedef AX_S32 SCD_CHN;
  201. //////////////////////////////////////////////////////////////////////////////////////
  202. /// @brief Initialize or uninitialize SCD module
  203. ///
  204. /// @param NA
  205. ///
  206. /// @return 0 if success, otherwise failure
  207. //////////////////////////////////////////////////////////////////////////////////////
  208. AX_S32 AX_IVES_SCD_Init(AX_VOID);
  209. AX_S32 AX_IVES_SCD_DeInit(AX_VOID);
  210. //////////////////////////////////////////////////////////////////////////////////////
  211. typedef struct axSCD_CHN_ATTR_S {
  212. SCD_CHN chn;
  213. AX_IVES_RECT_S stArea;
  214. AX_U8 u8Thrd; /* range: [1 - 100], recommend: 60 */
  215. AX_U8 u8Confidence; /* range: [1 - 100], recommend: 60 */
  216. } AX_SCD_CHN_ATTR_S;
  217. AX_S32 AX_IVES_SCD_CreateChn(SCD_CHN scdChn, const AX_SCD_CHN_ATTR_S *pstAttr);
  218. AX_S32 AX_IVES_SCD_DestoryChn(SCD_CHN scdChn);
  219. //////////////////////////////////////////////////////////////////////////////////////
  220. /// @brief Set or get channel attribute
  221. ///
  222. /// @param scdChn [I ]: specifies the SCD channel created.
  223. /// @param pstAttr [IO]: specifies the channel attribute to set [I] or get [O]
  224. ///
  225. /// @return 0 if success, otherwise failure
  226. /// If static parametes are changed, AX_ERR_ILLEGAL_PARAM error will be returned.
  227. //////////////////////////////////////////////////////////////////////////////////////
  228. AX_S32 AX_IVES_SCD_SetChnAttr(SCD_CHN scdChn, const AX_SCD_CHN_ATTR_S *pstAttr);
  229. AX_S32 AX_IVES_SCD_GetChnAttr(SCD_CHN scdChn, AX_SCD_CHN_ATTR_S *pstAttr);
  230. //////////////////////////////////////////////////////////////////////////////////////
  231. /// @brief Process image
  232. ///
  233. /// @param scdChn [I]: specifies the SCD channel created.
  234. /// @param pstImg [I]: specifies the image to process
  235. /// @param pResult [O]: return the detection result, 0: not change, 1: changed
  236. ///
  237. /// @return 0 if success, otherwise failure
  238. //////////////////////////////////////////////////////////////////////////////////////
  239. AX_S32 AX_IVES_SCD_Process(SCD_CHN scdChn, const AX_IVES_IMAGE_S *pstImg, AX_U8 *pResult);
  240. #ifdef __cplusplus
  241. }
  242. #endif
  243. #endif /* _AX_IVES_AP_H_80DEC0DA_BDEB_419F_85AD_3371389435C3_ */