资源简介
该代码实现了boosting算法的每一条步骤,用C++语言实现,比较完整。
代码片段和文件信息
// Boosting.cpp: implementation of the Boosting class.
//
//////////////////////////////////////////////////////////////////////
#include “stdafx.h“
#include “BoostingLbp.h“
#include “Boosting.h“
#include “math.h“
#include “stdio.h“
#include “Define.h“
#include “HarrFeature.h“
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Boosting::Boosting(DWORD posNum DWORD negNum)
{
PositiveNum = posNum;
NegativeNum = negNum;
TotalNegativeNum = negNum;
TotalSampleNum = PositiveNum + NegativeNum;
unsigned char *pFlag = new unsigned char[TOTAL_FEATURE_NUM];
// FILE *fFlag = fopen(SAVEPATH + “flag“ “rb“);
// fread(pFlag sizeof(unsigned char) TOTAL_FEATURE_NUM fFlag);
// fclose(fFlag);
memset(pFlag 1 TOTAL_FEATURE_NUM);
usedFeaCount = 0;
for (int c=0; c {
if (pFlag[c] == 1) usedFeaCount++;
}
delete []pFlag;
BinMin = NULL;
BinWidth = NULL;
FeaValue = NULL;
subWinInfo = new FeatureInfo[usedFeaCount];
Weight = new double[TotalSampleNum];
VotedValue = new double[TotalSampleNum];
Label = new unsigned char[TotalSampleNum];
memset(Label 1 PositiveNum);
memset(Label + PositiveNum 0 NegativeNum);
}
Boosting::~Boosting()
{
delete []BinMin;
BinMin = NULL;
delete []BinWidth;
BinWidth = NULL;
delete []Weight;
Weight = NULL;
delete []VotedValue;
VotedValue = NULL;
delete []Label;
Label = NULL;
if (NULL != FeaValue)
{
for(int i=0; i {
if(FeaValue[i] != NULL)
{
delete [] FeaValue[i];
FeaValue[i] = NULL;
}
}
FeaValue = NULL;
}
if (subWinInfo != NULL) delete []subWinInfo;
return;
}
//Quantize and the LBP bin distance.
void Boosting::Init(CString szPosName CString szNegName)
{
GetAllSubWinInfo();
printf(“\n“);
printf(“Total Weak Learner: %d\n“ usedFeaCount);
printf(“Positive Sample Number: %d\n“ PositiveNum);
printf(“Negative Sample Number: %d\n“ NegativeNum);
printf(“\n“);
CString szPosPath = szPosName;
CString szNegPath = szNegName;
FILE *PosFile = fopen(szPosPath “rb“);
FILE *NegFile = fopen(szNegPath “rb“);
//Quantize the distance to be between 0 and 99.
BinMin = new doubl
- 上一篇:C语言课设之校级运动会管理系统
- 下一篇:三次样条插值算法C++实现
评论
共有 条评论