#ifndef __I_CALIBRATION_H__
#define __I_CALIBRATION_H__

// *****************************************************************************
// 版权所有(C)2023~2099 上海骄成超声波技术有限公司
// 保留所有权利
// *****************************************************************************
// 作者 : 陆蕴凡
// 版本 : 1.0
// 代码创建日期:2024/12/6
// 版本更新日期:2024/12/6
// 功能说明:标定算法接口
// *****************************************************************************

#include <vector>
#include <string>
#include "TypeDef.h"

namespace JVision
{
	/**
	 * @brief 标定算法接口基类
	 *
	 */
	class JVision_API ICalibration
	{

	public:
		virtual ~ICalibration() = 0 {}

		/**
		 * @brief 九点手眼标定
		 *
		 * @param[in]  World_Points 机械坐标的集合 Point2D中x为机械列坐标,y为机械行坐标
		 * @param[in]  Image_Points 图像坐标的集合 Point2D中x为图像列坐标,y为图像行坐标
		 * @param[out] Result		矩阵的标定数据
		 *
		 * @return	ResultCode	0表示成功 其余表示失败
		 *
		 * @note 对应的错误码类型可以通过ExecuteErrorCode中接口获取失败信息
		 * @note 该接口必须在继承类中实现
		 */
		virtual ResultCode HandEyeCalibration(std::vector<JVision::Point2D> WorldPoints, std::vector<JVision::Point2D> ImagePoints, std::string& Result) = 0;

		/**
		 * @brief 旋转标定
		 *
		 * @param[in]  Image_Points 机械坐标的集合 Point2D中x为图像列坐标,y为图像行坐标
		 * @param[out] Result		输出参数,表示拟合的圆信息(世界坐标系)
		 *
		 * @return ResultCode      0表示成功 其余表示失败
		 *
		 * @note 对应的错误码类型可以通过ExecuteErrorCode中接口获取失败信息
		 * @note 该接口必须在继承类中实现
		 */
		virtual ResultCode RotateCalibraion(std::vector<JVision::Point2D> WorldPoints, CircleResult& Result) = 0;

		/**
		 * @brief 旋转坐标转换(机械坐标间转换)
		 *
		 * @param[in]  initialPoint			机械坐标
		 * @param[in]  angle				旋转角度(相对角度,顺时针为负,逆时针为正,angle)
		 * @param[in]  RotationCenter		旋转中心(机械坐标系)
		 * @param[out] Result				输出参数,转换后的旋转机械坐标
		 *
		 * @return ResultCode				0表示成功 其余表示失败
		 *
		 * @note 对应的错误码类型可以通过ExecuteErrorCode中接口获取失败信息
		 * @note 该接口必须在继承类中实现
		 */
		virtual ResultCode RotateAffine(Point InitialPoint, double angle, CircleResult RotationCenter, Point& Result) = 0;

		/**
		 * @brief 像素坐标转换成机械坐标
		 *
		 * @param[in]  initialPoint			像素坐标
		 * @param[in]  HandEyeMat			手眼矩阵
		 * @param[out] ResultWorld			输出参数,转换后的机械坐标
		 *
		 * @return ResultCode				0表示成功 其余表示失败
		 *
		 * @note 对应的错误码类型可以通过ExecuteErrorCode中接口获取失败信息
		 * @note 该接口必须在继承类中实现
		 */
		virtual ResultCode Image2WorldAffine(Point InitialImagePoint, std::string HandEyeMat, Point& ResultWorld) = 0;

		/**
		 * @brief 机械坐标转换成像素坐标
		 *
		 * @param[in]  initialPoint			机械坐标
		 * @param[in]  HandEyeMat			手眼矩阵
		 * @param[out] ResultImage		    输出参数,转换后的像素坐标
		 *
		 * @return ResultCode				0表示成功 其余表示失败
		 *
		 * @note 对应的错误码类型可以通过ExecuteErrorCode中接口获取失败信息
		 * @note 该接口必须在继承类中实现
		 */
		virtual ResultCode World2ImageAffine(Point InitialWorldPoint, std::string HandEyeMat, Point& ResultImage) = 0;

		/**
		 * @brief 检测手眼标定的精度
		 *
		 * @param[in]  CamCenter			相机中心坐标
		 * @param[in]  HandEye				手眼矩阵
		 * @param[out] Accuracy				标定误差:X方向与Y方向
		 *
		 * @return ResultCode				0表示成功 其余表示失败
		 *
		 * @note 对应的错误码类型可以通过ExecuteErrorCode中接口获取失败信息
		 * @note 该接口必须在继承类中实现
		 */
		virtual ResultCode InspectResult(Point2D CamCenter, const std::string& HandEye, Point2D& Accuracy) = 0;

		/**
		 * @brief 获取标定函数的实现类指针
		 */
		static ICalibration* GetCalibration();
	};
}

#endif