#ifndef __ILOCALIZATION_H__ #define __ILOCALIZATION_H__ // ***************************************************************************** // 版权所有(C)2023~2099 上海骄成超声波技术有限公司 // 保留所有权利 // ***************************************************************************** // 作者 : 李祥瑞 // 版本 : 1.0 // 代码创建日期:2024/11/19 // 版本更新日期:2024/11/21 // 功能说明: 定位算法接口 // ***************************************************************************** #include #include #include "CommonUtils.h" namespace JVision { // 定位算法接口 class JVision_API ILocalization { public: /** * @brief 构造函数 */ ILocalization() {} virtual ~ILocalization() {} /** * @brief 加载数据 * @param[in] path 文件路径 * * @return ResultCode 0: 成功, 其他: 失败 * * @note 该接口必须在继承类中实现 */ virtual ResultCode Load(const std::string& path) = 0; /** * @brief 存储数据 * @param[in] path 文件路径 * * @return ResultCode 0: 成功, 其他: 失败 * * @note 该接口必须在继承类中实现 */ virtual ResultCode Save(const std::string& path, const JVision::ImageInfo& initialImage) = 0; /** * @brief 获取算法名称 * * @note 该接口必须在继承类中实现 */ virtual std::string GetName() const = 0; /** * @brief 获取算法类型 * * @note 该接口必须在继承类中实现 */ virtual E_LOCALIZATION_TYPE GetLocalizionType() const = 0; /** * @brief 设置算法参数 * @param[in] id 参数id * @param[in] value 参数值 * * @return ResultCode 0: 成功, 其他: 失败 * * @note 该接口必须在继承类中实现 */ virtual ResultCode SetParameter(ParamID id, void* value) = 0; /** * @brief 设置预处理List * @param count * @return int 0: 成功, 其他: 失败 */ virtual void SetPreProcessList(std::vector& arr) = 0; /** * @brief 获取预处理List * @param count * @return int 0: 成功, 其他: 失败 */ virtual std::vector GetPreProcessList() = 0; /** * @brief 设置预处理参数 * @param id 参数id * @param value 参数值 * @param index 下标, 第几个预处理 * @return ResultCode 0: 成功, 其他: 失败 */ virtual ResultCode SetPreProcessParameter(ParamID id, void* value, int index) = 0; /** * @brief 获取算法参数 * @param[in] id 参数ID * * @return ResultCode 0: 成功, 其他: 失败 * * @note 该接口必须在继承类中实现 */ virtual void* GetParameter(ParamID id) const = 0; /** * @brief 获取所有的算法参数 * * @return map * * @note 该接口必须在继承类中实现 */ virtual std::map GetParameters() const = 0; /** * @brief 预处理图像 * @param[in] srcImg 源图像信息 * @param[in] keepFormat 预处理后的图像是否需要与源图像格式一致 * @param[out] dstImg 预处理后的图像信息 * * @return ResultCode 0: 成功, 其他: 失败 * * @note 该接口必须在继承类中实现 */ virtual ResultCode Preprocess(const ImageInfo& srcImg, ImageInfo& dstImg, bool keepFormat = true) = 0; /** * @brief 运行算法 * @param[in] srcImg 源图像信息 * @param[out] dstImg 处理后图像 * @param[out] markImg 模版图像 * @param[out] type 算法类型 * @param[in] result 结果流数据 * @param[out] resultSize 结果流数据内存大小 * * @return ResultCode 0: 成功, 其他: 失败 * * @note 该接口必须在继承类中实现 */ virtual ResultCode Run(const ImageInfo& srcImg, ImageInfo& dstImg, ImageInfo& markImg, E_LOCALIZATION_TYPE* type, unsigned char* result, size_t resultSize) = 0; /** * @brief 运行算法 * @param[in] srcImg 源图像信息 * @param[out] dstImg 处理后图像 * @param[out] markImg 模版图像 * @param[out] type 算法类型 * @param[in] result 结果流数据 * * @return ResultCode 0: 成功, 其他: 失败 * * @note 该接口必须在继承类中实现 */ virtual ResultCode RunLocalization(const ImageInfo& srcImg, ImageInfo& dstImg, ImageInfo& markImg, E_LOCALIZATION_TYPE* type, unsigned char** result) = 0; /** * @brief 对外算法接口 * @param[in] srcImg 传入的JVision图像结构体 * @param[out] dstImg 处理后的JVision图像结构体 * @param[out] type 当前的算法类型 * @param[out] **result 当前算法类型的结果流指针 * * @return ResultCode 算法执行成功返回0,失败返回其余的整数值 * * @note 该接口必须在继承类中实现 * @note 对应的错误码类型可以通过ExecuteErrorCode中接口获取失败信息 */ virtual ResultCode Run2(const ImageInfo& srcImg, ImageInfo& dstImg, E_LOCALIZATION_TYPE* type, unsigned char** result) = 0; /** * @brief 销毁结果流数据, 与Run2配合使用 * @param result 结果流数据 * * @note 该接口必须在继承类中实现 */ virtual void DestroyResult(unsigned char* result) = 0; /** * @brief 绘制结果 * @param[in] srcImg 源图像信息 * @param[in] *result 结果流数据 * @param[in] DrawContours 是否绘制轮廓 * @param[in] Result 定位结果的rgb信息 * @param[in] Contour 轮廓结果的rgb信息 * @param[out] dstImg 结果图像信息 * * @return ResultCode 0: 成功, 其他: 失败 * * @note 该接口必须在继承类中实现 */ virtual ResultCode Paint(const ImageInfo& srcImg, unsigned char* result, bool DrawContours, std::vectorResult, std::vectorContour, ImageInfo& dstImg) = 0; /** * @brief 获取算法存储的相机id */ virtual int GetCameraID() = 0; }; } #endif