#pragma once

#include "stdafx.h"

#define TRACK_WIN_SIZE	10
#define CALC_ROI_RADIUS 10

class CTracking
{
private:
	int				m_NumPoint;
	CvPoint2D32f	*m_Point[2];
	CvPoint			*m_PointInit;
	IplImage		*m_Gray;
	IplImage		*m_GrayPre;
	IplImage		*m_Pyramid;
	IplImage		*m_PyramidPre;
	IplImage		*m_Mask1;
	IplImage		*m_Mask2;
	IplImage		*m_Mask3;
	IplImage		*m_Mask4;
	char			*m_Status;
	CvTermCriteria	m_Criteria;
	int				m_PyrFlag;
	double			m_Movement;
	double			m_TotalMovement;
	bool			m_Validate;

private:
	void Release();
	void ValidatePoints();
	void CalcROIMask();

public:
	CTracking(void);
	~CTracking(void);
	bool Init(const CvPoint *point, const int numPoint,
		const IplImage *img);
	bool Frame(const IplImage *img);
	bool DrawPoints(IplImage *img);
	bool DrawROI(IplImage *img);
	double Movement() { return m_Movement; }
	double TotalMovement() { return m_TotalMovement; }
	bool IsVaildate() { return m_Validate; }
	CvScalar ROIColor1(IplImage *img);
	CvScalar ROIColor2(IplImage *img);
	CvScalar ROIColor3(IplImage *img);
	CvScalar ROIColor4(IplImage *img);
};
