本文整理汇总了C++中DataSet::ExtractPixel方法的典型用法代码示例。如果您正苦于以下问题:C++ DataSet::ExtractPixel方法的具体用法?C++ DataSet::ExtractPixel怎么用?C++ DataSet::ExtractPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSet
的用法示例。
在下文中一共展示了DataSet::ExtractPixel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LearnGAB
void GAB::LearnGAB(DataSet& pos, DataSet& neg){
const Options& opt = Options::GetInstance();
timeval start, end;
timeval Tstart, Tend;
float time = 0;
int nPos = pos.size;
int nNeg = neg.size;
float _FAR=1.0;
int nFea=0;
float aveEval=0;
float *w = new float[nPos];
if(stages!=0){
int fail = 0;
#pragma omp parallel for
for (int i = 0; i < nPos; i++) {
float score = 0;
if(NPDClassify(pos.imgs[i].clone(),score)){
pos.Fx[i]=score;
}
else{
fail ++;
}
}
if(fail!=0){
printf("you should't change pos data! %d \n",fail);
return;
}
MiningNeg(nPos,neg);
if(neg.imgs.size()<pos.imgs.size()){
printf("neg not enough, change neg rate or add neg Imgs %d %d\n",pos.imgs.size(),neg.imgs.size());
return;
}
pos.CalcWeight(1,opt.maxWeight);
neg.CalcWeight(-1,opt.maxWeight);
}
Mat faceFea = pos.ExtractPixel();
pos.ImgClear();
printf("Extract pos feature finish\n");
Mat nonfaceFea = neg.ExtractPixel();
printf("Extract neg feature finish\n");
for (int t = stages;t<opt.maxNumWeaks;t++){
printf("start training %d stages \n",t);
gettimeofday(&start,NULL);
vector<int> posIndex;
vector<int> negIndex;
for(int i=0; i<nPos; i++)
posIndex.push_back(i);
for(int i=0; i<nNeg; i++)
negIndex.push_back(i);
//trim weight
memcpy(w,pos.W,nPos*sizeof(float));
std::sort(&w[0],&w[nPos]);
int k;
float wsum;
for(int i =0;i<nPos;i++){
wsum += w[i];
if (wsum>=opt.trimFrac){
k = i;
break;
}
}
vector< int >::iterator iter;
for(iter = posIndex.begin();iter!=posIndex.end();){
if(pos.W[*iter]<w[k])
iter = posIndex.erase(iter);
else
++iter;
}
wsum = 0;
memcpy(w,neg.W,nNeg*sizeof(float));
std::sort(&w[0],&w[nNeg]);
for(int i =0;i<nNeg;i++){
wsum += w[i];
if (wsum>=opt.trimFrac){
k = i;
break;
}
}
for(iter = negIndex.begin();iter!=negIndex.end();){
if(neg.W[*iter]<w[k])
iter = negIndex.erase(iter);
else
++iter;
}
int nPosSam = posIndex.size();
int nNegSam = negIndex.size();
//.........这里部分代码省略.........