当前位置: 首页>>代码示例>>C++>>正文


C++ Forest::getTrees方法代码示例

本文整理汇总了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);
	
	

}
开发者ID:TLadd,项目名称:SeniorDesign,代码行数:28,代码来源:RandomFor.cpp

示例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);
	}

}
开发者ID:TLadd,项目名称:SeniorDesign,代码行数:36,代码来源:RandomFor.cpp


注:本文中的Forest::getTrees方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。