#pragma once

#include "cvcls.h"


#define RD_MIN_FRAME_COUNT  4
class CVCLS_API CRectifyDistortion
{
public:
	CRectifyDistortion(void){ m_bValid=FALSE;}
	virtual ~CRectifyDistortion(void){};

	//×îÐ¡4Ö¡Í¼Ïñ
	virtual BOOL  Train(int patternType, int rows, int cols,   int patternSize, const RvImage* images, int count, double* pTotalError)=0;
	virtual BOOL  Excute(RvImage image)=0;

	BOOL  IsTrained(){ return m_bValid; };

	virtual int Dump(TCHAR* strOut, int size){ return 0;}

protected:
 
	BOOL m_bValid ;
};

 
class CVCLS_API CRectifyFishEye: public CRectifyDistortion
{
public:
	CRectifyFishEye(void);
	virtual ~CRectifyFishEye(void);
	 
	virtual BOOL  Train(int patternType, int cols, int rows,    int patternSize, const RvImage* images, int count, double* pTotalError);
	virtual BOOL  Excute(RvImage image);
	virtual int Dump(TCHAR* strOut, int size);

	
	BOOL  GetIntrinsicMatrix(float* pMtx, int size); //3*3
	BOOL  GetDistortionCoeffs(float* pData, int size); //1*4

	BOOL  SetData(int width, int height, float intrinsic[9], float distortion[4]);

	int  GetCornerArrayAt(int index, RvPoint_f* pPointArrays, int arrSize);
	int   GetCornerArrayCount();

protected:
	 void ReleaseData();

	BOOL m_bValid;
	void* m_pData; 

};

