#if !defined(__RV_PIXEL_MATCH_E1_H_INCLUDED_)
#define      __RV_PIXEL_MATCH_E1_H_INCLUDED_

#include "pixelmatch.h"

//仅支持旋转，优化方法： 1. 新的搜索方法， 2. 支持背景模板
//                       3. 只找一个模板， 4. 增加轮廓点匹配
class PATMAT_API CPixelMatchE1 :	public CPixelMatch
{
public:
	CPixelMatchE1(void);
	virtual ~CPixelMatchE1(void);

	enum PM_SUBPIXEL{
		PM_SP_NONE=0,
		//PM_SP_BILINEAR, //插值
		PM_SP_MINERR0 =2,  //最小错误(基本精度, 角度最低1度, 像素最低1PIX)
		PM_SP_MINERR1,  //亚像素精度（低） 1/10 pix, 1/12.5 deg
		PM_SP_MINERR2,  //亚像素精度（中） 1/20 pix, 1/25 deg
		PM_SP_MINERR3,  //亚像素精度（高） 1/40 pix, 1/50 deg
	};
	 
	virtual BOOL    Learn(const RvImage image=NULL, int* pErrCode = NULL) ;
	virtual int     Recognize(const RvImage image=NULL, int* pErrCode = NULL);

	virtual BOOL Serialize(HANDLE device, BOOL bIn );
	virtual CUCObj* Clone(  CUCObj *twin) ;

	virtual void* GetPatternSet();
	virtual int GetPatternCount();	

public:
	void  ReleasePattE1Set(void* &pPattE1Set, int& nPattE1Size);
	void  ClonePattE1Set(void* pSourceSet, int nSrcSize, void** ppDestSet, int* pDestSize);
	void DumpPatterns(const TCHAR* strFilePath);

public:
   int        m_nSubPixelMethod; //亚像素精度方法	
   int        m_nSubPixelResample; //亚像素识别时的采样间隔	 ,0 不采样，1表示一个像素
 //  UINT       m_nMaxMemSize;

protected:
	 
	BOOL ReadEcdSet(HANDLE device, void** ppPatternSet, int* pPatterSize);
	BOOL WriteEcdSet(HANDLE device, void* pPatternSet, int size);

	void CalcLms(  RvImage image,  int transReso, int angleReso, BOOL bRotate);

	virtual RV_HANDLE DrawPatternInstances(HGDC dc, RV_HANDLE hStroke);
	BOOL BuildEdgeSamples(const RvImage image, const RvMask mask);

 
protected:
	int   m_nPattE1Size;
	void* m_pPattE1Set;
 
	//void ReattachPmPattern(void);
};




#endif

