int>,int> >& ferns,int resample);
void trainNN(const std::vector<cv::Mat>& nn_examples);
void NNConf(const cv::Mat& example,std::vector<int>& isin,float& rsconf,float& csconf);
void evaluateTh(const std::vector<std::pair<std::vector<int>,int> >& nXT,const std::vector<cv::Mat>& nExT);
void show();
//Ferns Members
int getNumStructs(){return nstructs;}
float getFernTh(){return thr_fern;}
float getNNTh(){return thr_nn;}
struct Feature //特征结构体
{
uchar x1, y1, x2, y2;
Feature() : x1(0), y1(0), x2(0), y2(0) {}
Feature(int _x1, int _y1, int _x2, int _y2)
: x1((uchar)_x1), y1((uchar)_y1), x2((uchar)_x2), y2((uchar)_y2)
{}
bool operator ()(const cv::Mat& patch) const
{
//二维单通道元素可以用Mat::at(i, j)访问,i是行序号,j是列序号
//返回的patch图像片在(y1,x1)和(y2, x2)点的像素比较值,返回0或者1
return patch.at<uchar>(y1,x1) > patch.at<uchar>(y2, x2);
}
};
//Ferns(蕨类植物:有根、茎、叶之分,不具花)features 特征组?
std::vector<std::vector<Feature> > features; //Ferns features (one std::vector for each scale)
std::vector< std::vector<int> > nCounter; //negative counter
std::vector< std::vector<int> > pCounter; //positive counter
std::vector< std::vector<float> > posteriors; //Ferns posteriors