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


C++ Evaluator::stopTimer方法代码示例

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


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

示例1: main

int main()
{
	Detector detector(5);												//instantiating a detector with kernel size 5
	Recognizer recognizer(detector);									//instantiating a recognizer
	Evaluator evaluator;												//instantiating an evaluator

	VideoCapture stream(1);												//capturing a stream from webcam (x)

	int letterIndex = 0;
	Mat capturedFrame;													//for holding the current frame
	char letter = letters[letterIndex] ;													//the letter to sign

	stream.read(capturedFrame);											//loads the first image so we can get the width and height of the video
	evaluator.openFiles(capturedFrame);									//opens all files so we can save the evaluation data

	/*
	 * FOR SETTING THRESHOLDS ONLY!
	 */
	Mat output;																//holds the processed frame
	//detector.createTrackbars();											//creates a window with trackbars

	int gloveNumber = 2;													//CHANGE BASED ON WHAT GLOVE YOU'RE TESTING!
																			//1 = fingertip-glove, 2 = wholefinger-glove, 3 = set threshold
	while (true){
		stream.read(capturedFrame);											//reading a frame from the stream

		if (gloveNumber == 1){

			detector.thresholdImageFor(capturedFrame, letter);				//thresholding for the chosen letter

			//imshow("blue thresh", detector.getBlueThreshImg());			//showing thresholded images
			//imshow("green thresh", detector.getGreenThreshImg());
			//imshow("red thresh", detector.getRedThreshImg());
			//imshow("yellow thresh", detector.getYellowThreshImg());

			recognizer.setDetector(detector);								//setting the detector for the recognizer

			if (evaluator.getTimerHasStarted() == false)					//if timer isn't currently going
				evaluator.startTimer(letter, capturedFrame, gloveNumber);	//start timer
			else															//saves the thresholded videos to a file
				evaluator.saveThreshVid(capturedFrame, detector.getBlueThreshImg(), detector.getGreenThreshImg(), detector.getPinkThreshImg(), detector.getRedThreshImg(), detector.getYellowThreshImg(), letter, gloveNumber);	//ensures every frame is saved to the video file

			//recognizer.recognize(letter, leftHand);						//recognizing for the chosen letter.
			recognizer.vectorRecognizer(letter, leftHand);
			//saves the BLOB videos to files
			evaluator.saveBLOBVid(recognizer.getBlueBLOBImg(), recognizer.getGreenBLOBImg(), recognizer.getPinkBLOBImg(), recognizer.getRedBLOBImg(), recognizer.getYellowBLOBImg(), letter, gloveNumber);

			if (recognizer.getLetterFound() == true){				//if recognizer found the sign we looked for
				evaluator.setEuclideanDistance(recognizer.getEuclideanDistance());	//set euclidean distance
				evaluator.stopTimer();						//stop timer and write to file
			}

			if (!recognizer.getBlueBLOBImg().empty())
				imshow("blue blob", recognizer.getBlueBLOBImg());			//Showing BLOB-analyzed images
			if (!recognizer.getGreenBLOBImg().empty())
				imshow("green blob", recognizer.getGreenBLOBImg());
			if (!recognizer.getRedBLOBImg().empty())
				imshow("red blob", recognizer.getRedBLOBImg());
			if (!recognizer.getYellowBLOBImg().empty())
				imshow("yellow blob", recognizer.getYellowBLOBImg());
			
		}
		else if (gloveNumber == 2){
			resize(capturedFrame, capturedFrame, Size(capturedFrame.cols / 3, capturedFrame.rows / 3));

			detector.thresholdForGlove2(capturedFrame);					//thresholding

			
			//imshow("blue thresh", detector.getBlueThreshImg());		//showing thresholded images
			//imshow("green thresh", detector.getGreenThreshImg());
			//imshow("pink thresh", detector.getPinkThreshImg());
			//imshow("red thresh", detector.getRedThreshImg());
			//imshow("yellow thresh", detector.getYellowThreshImg());

			recognizer.setDetector(detector);								//setting the detector for the recognizer

			if (evaluator.getTimerHasStarted() == false)					//if timer isn't currently going
				evaluator.startTimer(letter, capturedFrame, gloveNumber);	//start timer
			else															//saves the thresholded videos to files
				evaluator.saveThreshVid(capturedFrame, detector.getBlueThreshImg(), detector.getGreenThreshImg(), detector.getPinkThreshImg(), detector.getRedThreshImg(), detector.getYellowThreshImg(), letter, gloveNumber);	//ensures every frame is saved to the video file

			//recognizer.recognizeGlove2(letter, leftHand);					//recognizing for the chosen letter
			recognizer.vectorRecognizerGlove2(letter, leftHand);

			resize(capturedFrame, capturedFrame, Size(640, 480));

			String correct = "You are ";
			correct += to_string(recognizer.percentage(recognizer.getEuclideanDistance()));
			correct += "% correct";

			Scalar color;

			if (recognizer.percentage(recognizer.getEuclideanDistance()) < 90)
				color = Scalar(0, 0, 255);
			else
				color = Scalar(0, 255, 0);

			putText(capturedFrame, correct, Point(capturedFrame.cols / 3, capturedFrame.rows - capturedFrame.rows/6), FONT_HERSHEY_SIMPLEX, 0.8, color, 2);
			String letterStr = "";
			letterStr += letter;
//.........这里部分代码省略.........
开发者ID:eamea,项目名称:P3project,代码行数:101,代码来源:main.cpp


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