ILocalization.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. #ifndef __ILOCALIZATION_H__
  2. #define __ILOCALIZATION_H__
  3. // *****************************************************************************
  4. // 版权所有(C)2023~2099 上海骄成超声波技术有限公司
  5. // 保留所有权利
  6. // *****************************************************************************
  7. // 作者 : 李祥瑞
  8. // 版本 : 1.0
  9. // 代码创建日期:2024/11/19
  10. // 版本更新日期:2024/11/21
  11. // 功能说明: 定位算法接口
  12. // *****************************************************************************
  13. #include <map>
  14. #include <vector>
  15. #include "CommonUtils.h"
  16. namespace JVision
  17. {
  18. // 定位算法接口
  19. class JVision_API ILocalization
  20. {
  21. public:
  22. /**
  23. * @brief 构造函数
  24. */
  25. ILocalization() {}
  26. virtual ~ILocalization() {}
  27. /**
  28. * @brief 加载数据
  29. * @param[in] path 文件路径
  30. *
  31. * @return ResultCode 0: 成功, 其他: 失败
  32. *
  33. * @note 该接口必须在继承类中实现
  34. */
  35. virtual ResultCode Load(const std::string& path) = 0;
  36. /**
  37. * @brief 存储数据
  38. * @param[in] path 文件路径
  39. *
  40. * @return ResultCode 0: 成功, 其他: 失败
  41. *
  42. * @note 该接口必须在继承类中实现
  43. */
  44. virtual ResultCode Save(const std::string& path, const JVision::ImageInfo& initialImage) = 0;
  45. /**
  46. * @brief 获取算法名称
  47. *
  48. * @note 该接口必须在继承类中实现
  49. */
  50. virtual std::string GetName() const = 0;
  51. /**
  52. * @brief 获取算法类型
  53. *
  54. * @note 该接口必须在继承类中实现
  55. */
  56. virtual E_LOCALIZATION_TYPE GetLocalizionType() const = 0;
  57. /**
  58. * @brief 设置算法参数
  59. * @param[in] id 参数id
  60. * @param[in] value 参数值
  61. *
  62. * @return ResultCode 0: 成功, 其他: 失败
  63. *
  64. * @note 该接口必须在继承类中实现
  65. */
  66. virtual ResultCode SetParameter(ParamID id, void* value) = 0;
  67. /**
  68. * @brief 设置预处理List
  69. * @param count
  70. * @return int 0: 成功, 其他: 失败
  71. */
  72. virtual void SetPreProcessList(std::vector<ParamID>& arr) = 0;
  73. /**
  74. * @brief 获取预处理List
  75. * @param count
  76. * @return int 0: 成功, 其他: 失败
  77. */
  78. virtual std::vector<ParamID> GetPreProcessList() = 0;
  79. /**
  80. * @brief 设置预处理参数
  81. * @param id 参数id
  82. * @param value 参数值
  83. * @param index 下标, 第几个预处理
  84. * @return ResultCode 0: 成功, 其他: 失败
  85. */
  86. virtual ResultCode SetPreProcessParameter(ParamID id, void* value, int index) = 0;
  87. /**
  88. * @brief 获取算法参数
  89. * @param[in] id 参数ID
  90. *
  91. * @return ResultCode 0: 成功, 其他: 失败
  92. *
  93. * @note 该接口必须在继承类中实现
  94. */
  95. virtual void* GetParameter(ParamID id) const = 0;
  96. /**
  97. * @brief 获取所有的算法参数
  98. *
  99. * @return map<ParamID, ParamVal>
  100. *
  101. * @note 该接口必须在继承类中实现
  102. */
  103. virtual std::map<ParamID, void*> GetParameters() const = 0;
  104. /**
  105. * @brief 预处理图像
  106. * @param[in] srcImg 源图像信息
  107. * @param[in] keepFormat 预处理后的图像是否需要与源图像格式一致
  108. * @param[out] dstImg 预处理后的图像信息
  109. *
  110. * @return ResultCode 0: 成功, 其他: 失败
  111. *
  112. * @note 该接口必须在继承类中实现
  113. */
  114. virtual ResultCode Preprocess(const ImageInfo& srcImg, ImageInfo& dstImg, bool keepFormat = true) = 0;
  115. /**
  116. * @brief 运行算法
  117. * @param[in] srcImg 源图像信息
  118. * @param[out] dstImg 处理后图像
  119. * @param[out] markImg 模版图像
  120. * @param[out] type 算法类型
  121. * @param[in] result 结果流数据
  122. * @param[out] resultSize 结果流数据内存大小
  123. *
  124. * @return ResultCode 0: 成功, 其他: 失败
  125. *
  126. * @note 该接口必须在继承类中实现
  127. */
  128. virtual ResultCode Run(const ImageInfo& srcImg, ImageInfo& dstImg, ImageInfo& markImg, E_LOCALIZATION_TYPE* type, unsigned char* result, size_t resultSize) = 0;
  129. /**
  130. * @brief 运行算法
  131. * @param[in] srcImg 源图像信息
  132. * @param[out] dstImg 处理后图像
  133. * @param[out] markImg 模版图像
  134. * @param[out] type 算法类型
  135. * @param[in] result 结果流数据
  136. *
  137. * @return ResultCode 0: 成功, 其他: 失败
  138. *
  139. * @note 该接口必须在继承类中实现
  140. */
  141. virtual ResultCode RunLocalization(const ImageInfo& srcImg, ImageInfo& dstImg, ImageInfo& markImg, E_LOCALIZATION_TYPE* type, unsigned char** result) = 0;
  142. /**
  143. * @brief 对外算法接口
  144. * @param[in] srcImg 传入的JVision图像结构体
  145. * @param[out] dstImg 处理后的JVision图像结构体
  146. * @param[out] type 当前的算法类型
  147. * @param[out] **result 当前算法类型的结果流指针
  148. *
  149. * @return ResultCode 算法执行成功返回0,失败返回其余的整数值
  150. *
  151. * @note 该接口必须在继承类中实现
  152. * @note 对应的错误码类型可以通过ExecuteErrorCode中接口获取失败信息
  153. */
  154. virtual ResultCode Run2(const ImageInfo& srcImg, ImageInfo& dstImg, E_LOCALIZATION_TYPE* type, unsigned char** result) = 0;
  155. /**
  156. * @brief 销毁结果流数据, 与Run2配合使用
  157. * @param result 结果流数据
  158. *
  159. * @note 该接口必须在继承类中实现
  160. */
  161. virtual void DestroyResult(unsigned char* result) = 0;
  162. /**
  163. * @brief 绘制结果
  164. * @param[in] srcImg 源图像信息
  165. * @param[in] *result 结果流数据
  166. * @param[in] DrawContours 是否绘制轮廓
  167. * @param[in] Result 定位结果的rgb信息
  168. * @param[in] Contour 轮廓结果的rgb信息
  169. * @param[out] dstImg 结果图像信息
  170. *
  171. * @return ResultCode 0: 成功, 其他: 失败
  172. *
  173. * @note 该接口必须在继承类中实现
  174. */
  175. virtual ResultCode Paint(const ImageInfo& srcImg, unsigned char* result, bool DrawContours, std::vector<int>Result, std::vector<int>Contour, ImageInfo& dstImg) = 0;
  176. /**
  177. * @brief 获取算法存储的相机id
  178. */
  179. virtual int GetCameraID() = 0;
  180. };
  181. }
  182. #endif