用C语言实现的基于adaboost算法的人脸检测程序及人脸库


用C语言实现的基于adaboost算法的人脸检测程序及人脸库
资源截图
代码片段和文件信息
#include “cv.h“
#include “highgui.h“
//cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#ifdef _EiC
#define WIN32
#endif

//#define NUM_SAMPLES_MAX 501

#define NUM_SAMPLES_MAX 7000
#define HAAR_FEATURE_MAX 3
#define WEAKCLASSIFIER_NUM_MAX 300
#define Sample_W 19
#define Sample_H 19


int Image_Mg[2000][2000];

int every_haarfeature_value[NUM_SAMPLES_MAX];//全局数组变量用来保存所有样本的每个特征值,用于Cal_Allsamples_Featurej函数


typedef struct HaarFeature //一个HaarFeature对应于一个弱分类器
{
   
int N;
int kind; //kind=1、2、3、4、5分别对应论文中的五种haar特征
CvRect r;

int threshold; //弱分类器阈值
int p; //不等号方向
double we; //权重错误率
//float e; //弱分类器对所有样本的分类错误率

//int n; //实际样本数量
//int Samples_FeatureValue[NUM_SAMPLES_MAX]; //用来保存所有样本的特征值
//int Sorted_Value[NUM_SAMPLES_MAX]; //所有样本排序后的特征值
double btt ; //
//char hy[NUM_SAMPLES_MAX];
}
HaarFeature;

HaarFeature Haarfeatures[78500];

int num_features=0;

typedef struct SimpleHaarFeature //一个HaarFeature对应于一个弱分类器
{
int kind; //kind=1、2、3、4、5分别对应论文中的五种haar特征
CvRect r;
int threshold; //弱分类器阈值
int p; //不等号方向
double we; //权重错误率
//float e; //弱分类器对所有样本的分类错误率

}
SimpleHaarFeature;


typedef struct Ex_IplImage
{
IplImage * image;
//CvMat * Mg;
int Mg[Sample_W + 1][Sample_H + 1]; //used to keep jifen of grey pixel
int N; //the image‘s number in all samples
int Y; //sign for positive of face or not
int F; //the feature valuebe used to sort
double W; //the image‘s weight
int IsFalseDetected;
}
Ex_IplImage;

Ex_IplImage Samples[NUM_SAMPLES_MAX];

int num_samples;


typedef struct NYFW
{
int N; //the image‘s number in all samples
int Y; //sign for positive of face or not
int F; //the feature value
double W; //the image‘s weight
}
NYFW;



/* a boosted battery of classifiers(=stage classifier):
   the stage classifier returns 1
   if the sum of the classifiers‘ responces
   is greater than threshold and 0 otherwise */
typedef struct HaarStageClassifier
{
    int  count; /* number of classifiers in the battery */
    double threshold; /* threshold for the boosted classifier */
    HaarFeature classifier[WEAKCLASSIFIER_NUM_MAX]; /* array of classifiers pointer*/
double alphat[WEAKCLASSIFIER_NUM_MAX]; // array of at for every chassifier

    /* these fields are used for organizing trees of stage classifiers
       rather than just stright cascades */
    int next;
    int child;
    int parent;
}
HaarStageClassifier;

/*
typedef struct CvAvgComp
{
CvRect rect; //bounding rectangle for the object (average rectangle of a group) 
int neighbors; // number of neighbor rectangles in the group 
}
CvAvgComp;
*/

void Output_Haarfeature(int i)
{
printf(“第%6d个Haar特征如下:

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     208100  2011-03-17 21:20  Rapid_object_Detection_using_a_Boosted_cascade_of_simple_features1.pdf

     文件     102551  2011-06-07 14:47  pain.cpp

     文件      36435  2011-05-07 15:34  MIT人脸库faceface.txt

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00001.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00002.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00003.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00004.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00005.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00006.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00007.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00008.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00009.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00010.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00011.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00012.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00013.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00014.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00015.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00016.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00017.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00018.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00019.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00020.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00021.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00022.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00023.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00024.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00025.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00026.bmp

     文件       1254  2004-05-02 18:55  MIT人脸库faceface00027.bmp

............此处省略22460个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)