本文整理汇总了C++中Forest::getTrees方法的典型用法代码示例。如果您正苦于以下问题:C++ Forest::getTrees方法的具体用法?C++ Forest::getTrees怎么用?C++ Forest::getTrees使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Forest
的用法示例。
在下文中一共展示了Forest::getTrees方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trainTree
void trainTree(string treeFile, string trainDir) {
SerializeHelper sHelp = SerializeHelper();
ImageReader imReader = ImageReader();
vector<Mat> depthImages = imReader.readDepthImages(trainDir);
vector<Mat> classifiedImages = imReader.readClassifiedImages(trainDir);
int times = clock();
// 7 classes, 15 deep, 200 features, 50 thresholds, 0.02 subsampling, 1 minnuminnode, 10 background penalty, feature range, threshold range
Forest forest = Forest(6, 15, 500, 100, 0.05, 10, 0, pair<double, double>(150, 150), pair<double, double>(-255,255));
// 500 image per tree. Three made at once.
forest.makeTrees(depthImages, classifiedImages, 150, 3);
int timed = clock();
cout << "Making trees took "<< (timed-times) <<" ticks.\n"<< endl;
//Forest forest = sHelp.loadForest("MediumTree100F1000.txt");
sHelp.serializeForest(forest, treeFile);
string graphvix = forest.getTrees().at(0)->graphvizPrint(-1, NULL);
}
示例2: runPrediction
void runPrediction(string treeFile, string testDir, bool writeToFile, string outputFileName) {
SerializeHelper sHelp = SerializeHelper();
Forest forest = sHelp.loadForest(treeFile);
string graphvix = forest.getTrees().at(0)->graphvizPrint(-1, NULL);
ofstream graphvizFile("graphvizForest.txt");
graphvizFile << graphvix;
ImageReader imReader = ImageReader();
vector<Mat> testDepthImages = imReader.readTrainingImages(testDir);
for(int k=0; k < testDepthImages.size(); k++) {
Mat classified = forest.classifyImage(testDepthImages.at(k));
std::ostringstream path;
path << outputFileName << "/" << k+1 << "Y.png";
string windowName = path.str();
//namedWindow( windowName, WINDOW_AUTOSIZE );
//Mat cimg = convertToColorForBaby(classified);
if(writeToFile) {
//imwrite(windowName, cimg);
imwrite(windowName, classified);
}
//imshow(windowName, cimg);
//imshow(windowName, classified);
waitKey(30);
}
}