www.pudn.com > faces.rar > fr.h


/*** 
 **     libface - Library of face recognition and supporting algorithms 
        Copyright (c) 2003 Stefan Farthofer 
 
	This file is part of libface, which is 
 
        free software; you can redistribute it and/or modify 
        it under the terms of the GNU General Public License as published by 
        the Free Software Foundation; either version 2 of the License, or 
        (at your option) any later version. 
 
        This program is distributed in the hope that it will be useful, 
        but WITHOUT ANY WARRANTY; without even the implied warranty of 
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
        GNU General Public License for more details. 
 
        You should have received a copy of the GNU General Public License 
        along with this program; if not, write to the Free Software 
        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 
	For further information seek us at http://sourceforge.net/projects/openbio/ 
**	or write an email to dimitri.pissarenko@gmx.net or farthofer@chello.at. 
***/ 
 
#ifndef __FR_H 
#define __FR_H 
 
/* --------- STRUCTURES ----------- */ 
/* used to hold data computed by an recognitionMethod (e.g. feature vector for eigenfaces) */ 
struct sImageTrait { 
	BYTE *data; 
}; 
#define FRimageTrait struct sImageTrait 
 
struct sImage { 
	unsigned int width;		/* width and height of the image */ 
	unsigned int height; 
	float *imgdata;			/* pointer to image data */ 
}; 
#define FRimage struct sImage 
 
/* contains global data for a recognition algorithm, e.g. feature vectors for the 
 * eigenfaces approach 
 */ 
struct sTrainedData { 
	unsigned int id;	/* unique id, i could use one algorithm more than once */ 
	int algorithmType;	/* which algorithm */ 
	BYTE *data;			/* size is not needed, this is known by the alogrithm implementation */ 
}; 
#define FRtrainedData struct sTrainedData 
 
/* parameters for recognition, may contain several FRtrainedData entries for the various  
 * recognition methods to use 
 */ 
struct sRecognitionParameters { 
	unsigned int width;			/* width and height of faces */ 
	unsigned int height; 
	unsigned int nextId;	/* used for unique ids for algorithm entries */ 
	unsigned int faceFinder;	/* id of the face finder to use or 0 if non */ 
	unsigned int nrAlgorithms;	/* used algorithms */ 
	FRtrainedData *algorithms; 
}; 
#define FRrecognitionParameters struct sRecognitionParameters 
 
/* used to pass parameters to an reognition or finder alogrithm */ 
struct sAlgoParam { 
	int id; /* id of parameter, algorithm specific */ 
	BYTE* data; 
}; 
#define FRalgoParam struct sAlgoParam 
 
/* box, used by finders to return face position, defines an arbitrary rectangle */ 
struct sBox { 
	float x1,x2,x3,x4,y1,y2,y3,y4; 
}; 
#define FRbox struct sBox 
 
 
/* --------- FUNCTIONS ----------- */ 
/* init */ 
int frInit(void); 
 
/* image load/save */ 
int frImgLoadBound(FRimage* image); 
int frImgLoadFile(char* filename, FRimage* image); 
int frImgSaveFile(char* filename, FRimage* image); 
int frImgLoadMem(void* mem, size_t sz, FRimage* image, ILenum type); 
int frImgLoadRaw(void* mem, int width, int height, FRimage* image); 
int frImgGetILImg(ILuint* imgnr, FRimage* image); 
int frImgGetILImgFloat(ILuint* imgnr, FRimage* image); 
void frImgFree(FRimage* image); 
int frImgResize(FRimage* dst, FRimage* src, unsigned int w, unsigned int h); 
 
/* recognition parameter setup */ 
int frRecoParamsAddAlogrithm(FRrecognitionParameters* gParms, int type, FRalgoParam* algoParms, unsigned int nrAlgoParms, FRimage* images, unsigned int nrImages); 
int frRecoParamsRemoveAlgorithm(FRrecognitionParameters* gParms, unsigned int id); 
 
/* recognition parameter serialize */ 
int frRecoParamsCreate(FRrecognitionParameters** gParms); 
int frRecoParamsLoadFile(FILE* fileHandle, FRrecognitionParameters** gParms); 
int frRecoParamsSaveFile(FILE* fileHandle, FRrecognitionParameters* gParms); 
size_t frRecoParamsGetSize(FRrecognitionParameters* gParms); 
int frRecoParamsSerialize(BYTE** mem, size_t maxsz, FRrecognitionParameters** gParms, BYTE direction); 
void frRecoParamsFree(FRrecognitionParameters** gParms); 
 
/* calculate traits */ 
int frTraitsCalc(FRrecognitionParameters* gParms, FRimage* rawImage, FRimageTrait** traits); 
 
/* traits serialize */ 
int frTraitsSaveFile(FRrecognitionParameters* gParms, FILE* fileHandle, FRimageTrait* traits); 
int frTraitsLoadFile(FRrecognitionParameters* gParms, FILE* fileHandle, FRimageTrait** traits); 
size_t frTraitsGetSize(FRrecognitionParameters* gParms, FRimageTrait* traits); 
int frTraitsSerialize(FRrecognitionParameters* gParms, BYTE** mem, size_t maxsz, FRimageTrait** traits, BYTE direction); 
void frTraitsFree(FRrecognitionParameters* gParms, FRimageTrait** traits); 
 
/* compare traits */ 
int frCmp(FRrecognitionParameters* parms, FRimageTrait* traits1, FRimageTrait* traits2, float* match); 
 
/* face finder */ 
int frFindFaces(int finder, FRimage* image, FRbox** boxes, unsigned int* nrBoxes); 
int frFindFaceAndProcess(int finder, FRimage* in, FRimage** out, unsigned int w, unsigned int h); 
 
/* preprocessor */ 
int frPreprocess(int preprocessor, FRimage* in, FRimage** out, FRbox* box, int w, int h); 
 
#endif /* __FR_H */