⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcadll.h

📁 face recognition test source code
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef PCADLLH_H
#define PCADLLH_H

#define WM_PUTINFO	WM_USER + 100

/*#ifndef __cplusplus
extern "C" {
#endif*/ /*__cplusplus*/

void GiveProcess();
void Msg(int level, char *format, ...);
void Fail(int err);
void ByteToStr(char *str, long byte);
long lmin(long i1, long i2);

/*#ifndef __cplusplus
}
#endif*/ /*__cplusplus*/

#endif /*PCADLLH_H*/

/*--------------------------------------------------------------------------------------------*/

#ifndef MYEXCPT_H
#define MYEXCPT_H

class CMyException : public CException
	{
	public:
		CMyException();
		CMyException(int i);
		
		int err;
	};

#endif /*MYEXCPT_H*/

/*--------------------------------------------------------------------------------------------*/

#ifndef DEF_H
#define DEF_H

#define XSPACE		5
#define YSPACE		5
#define YFACETEXT	3
#define YTEXT		12
#define MAXXFACE	10
#define MAXFLOAT 	30000

/* Commands */
#define CMD_TRAINING							0
#define CMD_RECONSTRUCTION					1
#define CMD_RECOGNIZE						2
#define CMD_MEET								3
#define CMD_LOAD_EIGEN						4
#define CMD_SAVE_EIGEN_DB					5
#define CMD_SAVE_EIGEN						6
#define CMD_SAVE_REPORT						7
#define CMD_SAVE_CMP_MEET					8
#define CMD_SAVE_CMP_RECONSTRUCTION		9
#define CMD_SAVE_CMP_RECOGNITION			10
#define CMD_MAX								11

typedef struct _GEOMPARAMS
	{
	int xNum;						/*Number of columns of faces */
	int yNum;						/*Number of lines of faces -1*/
	int lastNum;					/*Number of columns of faces on the last line*/
	}GEOMPARAMS;

typedef struct _CORNER
	{
	int x, y;
	}CORNER;

#endif /* DEF_H */

/*--------------------------------------------------------------------------------------------*/

#ifndef MEMORY_H
#define MEMORY_H

class CMemory	
	{
	public:
		CMemory();
		~CMemory();
		
		void FAR	*GetPtr();
		int 		ReleasePtr();
		int 		Allocate(long lsizet);
		int 		Reallocate(long lsizet);
		
		long		GetSize();
		HGLOBAL	GetHandle();
		
	private:
		HGLOBAL 	handle;
		long 		lsize;
	};

#endif /*MEMORY_H*/

/*--------------------------------------------------------------------------------------------*/

#ifndef MATRIX_H
#define MATRIX_H

#define		valtype	float
#define		valtype2	float
#define 		MAX_NAME 10

class CMatrixSym;
class CVect;
class CDiag;

class CMatrix : public CObject
	{
	protected:
		long col, li;         						/*Number of columns and lines of the matrix*/
		CMemory *pMem;								/*Ptr to a CMemory obj containing the*/
													/*values : a(1,1) a(1,2) ... a(1,col) ... a(li,col)*/
		valtype *pData;								/*Pointer to the matrix's value if pMem is locked*/
		BOOL bTranspose;							/*tells if the matrix is transposed*/
		BOOL bLocked;								/*tells if pMem is locked */
      char **name;											/*points to a list of string, containing the name of each column vector*/

	public:
		CMatrix();
		CMatrix(long l, long c);
		~CMatrix();
		int Save(char *filename);
		int Load(char *filename);
		void Add(CMatrix *pMat2);					/*Add to this matrix the matrix pMat2*/
		void Multiply(CMatrix *pMat1, CMatrix *pMat2, BOOL bResize = FALSE, long lNewRow = 0, long lNewCol = 0);
													/*Put into this pMat1*pMat2*/
		void Multiply(CDiag *pDiag, BOOL bResize = TRUE);
													/*Multiply this matrix by the diagonal matrix pDiag*/
		void NormalizeCol();						/*Normalize each column*/
		void OuterProduct(CMatrixSym *pMat);		/*Compute the outer product of pMat*/
		void InnerProduct(CMatrixSym *pMat);		/*Compute the inner product of pMat*/
		void InnerProduct(CMatrix *pMat);			/*Compute the inner product of pMat*/
		void Initialize();							/*Sets all the elements to 0*/
		void SetTranspose(BOOL bTransposet);		/*Set the bTranspose parameter*/
		virtual long GetCol();
		virtual long GetLi();
		virtual void Lock();						/*Lock pMem and validate pData*/
		virtual void Unlock();						/*Unlock pMem and Unvalidate pData*/
		virtual int Eigen(CVect *ev, long leigen);	/*Compute the eigenvectors of this matrix*/
		void Expand(long c, float *scale, float *shift, valtype dest_min, valtype dest_max);
		
		int GetColName(long c, char *str, int len);	/*copy in str the name of the column vector c*/
		int SetColName(long c, char *str);				/*set the name of the column vector c to str*/
		
	public:
		virtual void Allocate(long, long);
		virtual void Allocate();					/*Allocate (or reallocate) the memory*/
													/*needed by pData; Call the CMemory's Allocate fct*/
	public:
		virtual valtype GetAt(long l, long c);
		virtual void SetAt(long l, long c, valtype value);
	};
	
#endif /*MATRIX_H*/

/*--------------------------------------------------------------------------------------------*/

#ifndef MATRIXPTR_H
#define MATRIXPTR_H

class CMatrixPtr : public CMatrix
	{
	private:
		CMemory **pColPtr;							/*Locked pointer of CMatrix's pMem*/
													/*pMem contain the CMemory pointer to the columns of the matrix*/
		CMemory *pMemPtr;							/*Array of memory containing the pointers to the columns' values*/
		valtype2 **pData2;								/*Locked pointer of pMemPtr. So it contains the pointers to the values*/
		BOOL bAlloc;
		
	public:
		CMatrixPtr();
		CMatrixPtr(long l, long c);
		~CMatrixPtr();
		virtual valtype2 GetAt(long l, long c);			/*Get the element at (l,c) of the matrix*/
													/*if bTranspose == FALSE, and of the*/
													/*transposed matrix if bTranspose == TRUE*/
		virtual void SetAt(long l, long c, valtype2 value);
													/*Obvious. Becarful to bTranspose*/
		virtual void Lock();
		virtual void Unlock();
		void SetColumn(long c, CMemory *pCol);
													/*Assign the column c of the matrix to the memory vector pCol*/
		CMemory *GetColumn(long c);					/*Return the column c of the matrix as a CMemory object*/
		virtual void Allocate();					/*Allocate (or reallocate) the memory*/
													/*needed by pData; Call the CMemory's Allocate fct*/
		virtual void Allocate(long, long);			/*set li and col, call Allocate() and AllocateCol()*/
		void AllocateCol();							/*Allocate memory for the coulmns' data*/
		void FreeCol();								/*free the memory for the columns data*/
		void InvertCol();							/*Invert the order of this matrix*/
		void SwapCol(long l1, long l2);				/*Swap the order of two columns*/
		void Discard(long l);						/*Discard a column*/
	};

#endif /*MATRIXPTR_H*/

/*--------------------------------------------------------------------------------------------*/

#ifndef MATRXSYM_H
#define MATRXSYM_H

class CMatrixSym : public CMatrix
	{
	private:
	public:
		CMatrixSym();
		CMatrixSym(long l);
		~CMatrixSym();
		virtual long GetCol();
		virtual long GetLi();
		
		int Eigen(CMatrix *Q, CVect *ev);	/* Puts in Q the eigenvectors and in ev the eigenvalues of the matrix*/
		int Put(CMatrix *Q);				/* Puts all the elements of this matrix into the pointer to a CMatrix object*/
	private:
		virtual void Allocate();			/*Allocate (or reallocate) the memory*/
											/*needed by pData; Call the CMemory's Allocate fct*/
	public:
	virtual valtype GetAt(long l, long c);
	virtual void SetAt(long l, long c, valtype value);
	};

#endif /*MATRXSYM_H*/

/*--------------------------------------------------------------------------------------------*/

#ifndef CVECT_H
#define CVECT_H

class CVect
	{
	protected:
		long li;	         						/*Number of rows of the vector*/
		CMemory *pMem;								/*Ptr to a CMemory obj containing the*/
													/*values : a(1,1) a(1,2) ... a(1,col) ... a(li,col)*/
		valtype *pData;								/*Pointer to the matrix's value if pMem is locked*/
		BOOL bLocked;								/*tells if pMem is locked */
	public:
		CVect();
		CVect(long c);
		~CVect();
		int Save(char *);							/*Save the vector in a text file*/
		int Load(char *);							/*Load the vector from a text file*/
		void Initialize();							/*Sets all the elements to 0*/
		long GetLi();
		void Lock();								/*Lock pMem and validate pData*/
		void Unlock();								/*Unlock pMem and Unvalidate pData*/
		void PowCmp(float exp);						/*Pow each individual composant of the vector*/
		
		void Allocate();							/*Allocate (or reallocate) the memory*/
													/*needed by pData; Call the CMemory's Allocate fct*/
		void Invert();								/* Invert the order of the columns, but keep the matrix diagonal*/
		void SwapCol(long l1, long l2);				/*Swap two elements*/
		void Discard(long l);						/*Discard one element*/	
		valtype GetAt(long l)
		 	/*{
#ifdef CHECK_BOUNDARY
		 	if (l <= 0 || l > li)
		 	 	Fail(NULL);
#endif
			return pData[l-1L];
		 	}*/;
		void SetAt(long l, valtype value)
		 	/*{
#ifdef CHECK_BOUNDARY
		 	if (l <= 0 || l > li)
		 		Fail(NULL);
#endif		 
			pData[l-1L] = value;
		 	}*/; 
	};
	
#endif /* CVECT_H */

/*--------------------------------------------------------------------------------------------*/

#ifndef CDIAG_H
#define CDIAG_H

class CDiag : public CVect
	{
	protected:
		
	public:
		CDiag();
		CDiag(long c);
		~CDiag();
	
		void Inverse();
		void Pow(float exp);
		long GetCol();
		void Multiply(CMatrix *pMat1, CMatrix *pMat2);
	};
	
#endif /* CDIAG_H */

/*--------------------------------------------------------------------------------------------*/

#ifndef CFACE_H
#define CFACE_H

//#include <stdio.h>

#define ASCII		0
#define BINARY		1
#define PPM			0
#define PGM			1
#define typeface	float

class CFace	: public CObject	
	{
	public:
		CFace();
		CFace(long, long);
		CFace(char *tFileName, char *tFaceName);
		~CFace();
		
		int Load();
		int Save();
		int Copy(CMatrixPtr *pMat, long c);
		void Allocate();
		
		void Expand(float *scale, float *shift, float src_min, float src_max);
		
		void SetFileName(char *str_file);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -