aihot  2017-04-27 20:10:03  OpenCV |   查看评论   
void FerNNClassifier::update(const vector<int>& fern, int C, int N) {  
  •   int idx;  
  •   for (int i = 0; i < nstructs; i++) {  
  •       idx = fern[i];  
  •       (C==1) ? pCounter[i][idx] += N : nCounter[i][idx] += N;  
  •       if (pCounter[i][idx]==0) {  
  •           posteriors[i][idx] = 0;  
  •       } else {  
  •           posteriors[i][idx] = ((float)(pCounter[i][idx]))/(pCounter[i][idx] + nCounter[i][idx]);  
  •       }  
  •   }  
  • }  
  •   
  • //训练集合分类器(n个基本分类器集合)  
  • void FerNNClassifier::trainF(const vector<std::pair<vector<int>,int> >& ferns,int resample){  
  •   // Conf = function(2,X,Y,Margin,Bootstrap,Idx)  
  •   //                 0 1 2 3      4         5  
  •   //  double *X     = mxGetPr(prhs[1]); -> ferns[i].first  
  •   //  int numX      = mxGetN(prhs[1]);  -> ferns.size()  
  •   //  double *Y     = mxGetPr(prhs[2]); ->ferns[i].second  
  •   //  double thrP   = *mxGetPr(prhs[3]) * nTREES; ->threshold*nstructs  
  •   //  int bootstrap = (int) *mxGetPr(prhs[4]); ->resample  
  •     
  •   //thr_fern: 0.6 thrP定义为Positive thershold  
  •   thrP = thr_fern * nstructs;                                    // int step = numX / 10;  
  •   //for (int j = 0; j < resample; j++) {                      // for (int j = 0; j < bootstrap; j++) {  
  •       for (int i = 0; i < ferns.size(); i++){               //   for (int i = 0; i < step; i++) {  
  •                                                             //     for (int k = 0; k < 10; k++) {  
  •                                                             //       int I = k*step + i;//box index  
  •                                                             
  •  

    除特别注明外,本站所有文章均为 赢咖4注册 原创,转载请注明出处来自TLD(Tracking-Learning-Detection)学习与源码理解之(七)

    留言与评论(共有 0 条评论)
       
    验证码:
    [lianlun]1[/lianlun]