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


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

本文整理汇总了C++中Forest::classifyImage方法的典型用法代码示例。如果您正苦于以下问题:C++ Forest::classifyImage方法的具体用法?C++ Forest::classifyImage怎么用?C++ Forest::classifyImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Forest的用法示例。


在下文中一共展示了Forest::classifyImage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: classifyOneImage

void classifyOneImage(string forest, string depthFile) {
	Mat depthImage = imread(depthFile, 0);

	SerializeHelper sHelp = SerializeHelper();
	Forest f = sHelp.loadForest(forest);

	Mat classified = f.classifyImage(depthImage);

	Mat cimg = convertToColorForBaby(classified);

	imshow("Hopethisworks", cimg);

	waitKey(30);
}
开发者ID:TLadd,项目名称:SeniorDesign,代码行数:14,代码来源: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

示例3: main

int main( int argc, char** argv )
{
    help();

    VideoCapture capture;

    
	SerializeHelper sHelp = SerializeHelper();
	Forest forest = sHelp.loadForest("adult.txt");

	// Open webcam
	capture.open(CV_CAP_INTELPERC);
	//cap.open("d2.avi");

    if( !capture.isOpened() )
    {
        cout << "Could not initialize capturing...\n";
        return -1;
    }

	capture.set(CV_CAP_INTELPERC_IMAGE_GENERATOR | CV_CAP_PROP_INTELPERC_PROFILE_IDX, 0);
	capture.set(CV_CAP_INTELPERC_DEPTH_GENERATOR | CV_CAP_PROP_INTELPERC_PROFILE_IDX, 0);

    namedWindow( "Depth", 1 );
	namedWindow( "Color", 1 );

    Mat gray, prevGray, image;
    vector<Point2f> points[2];

	//rect =


	ImagePacket images = getFrames(capture);

	Mat threshDepth;

	int threshDist = 750;

	threshold(images.getDepth(), threshDepth, threshDist, 100000, THRESH_TOZERO_INV);
	
	threshDepth.convertTo(threshDepth, CV_8U);

	Mat segmentedImage = forest.classifyImage(threshDepth);

	imshow("Segmentation", convertToColorForBaby(segmentedImage));


	Rect rect = isolateBodyPart(segmentedImage, HEAD);

	TemplateTracker hTrack = TemplateTracker();


	cvWaitKey(10);

	hTrack.initialize(rect, images.getColor(), threshDepth, 0);

	Mat color, uvMap;
    for(;;)
    {
        ImagePacket images = getFrames(capture);

		threshold(images.getDepth(), threshDepth, threshDist, 100000, THRESH_TOZERO_INV);
	
		threshDepth.convertTo(threshDepth, CV_8U);


		hTrack.track(images.getColor(), threshDepth);

		forehead = getForeheadFromHead(hTrack.getTrackedRegion());
	
		color = images.getColor();
		uvMap = images.getUVMap();


		Mat foreheadDepth = threshDepth(forehead);
		imshow("forehead", foreheadDepth);

		transpose(threshDepth, threshDepth);
		transpose(color, color);
		transpose(foreheadDepth, foreheadDepth);

		

		for(int i = 0; i < foreheadDepth.rows; i++) {
			for(int j = 0; j < foreheadDepth.cols; j++) {
				if(foreheadDepth.at<uchar>(i,j) != 0) {
					Point cPoint = translateDepthToColor(Point(j+forehead.y, i+forehead.x), color, uvMap);

					if(cPoint.x < color.cols && cPoint.y < color.rows)
						circle( color, cPoint, 3, Scalar(0,255,0), -1, 8);
				}
			}

		}

		transpose(threshDepth, threshDepth);
		transpose(color, color);

		rectangle(threshDepth, hTrack.getTrackedRegion(), Scalar(255, 0, 0), 2, 8, 0);
		rectangle(threshDepth, forehead, Scalar(255, 0, 0), 2, 8, 0);
//.........这里部分代码省略.........
开发者ID:TLadd,项目名称:SeniorDesign,代码行数:101,代码来源:Vitals.cpp


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