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


C++ ImageProcessor::process_image方法代码示例

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


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

示例1: test_video

void test_video() {

	VideoCapture cap(CV_CAP_ANY);
	ImageProcessor processor;
	ImageLoader loader;
	NeuralNetwork net;
	net.load(NET_FILE_NAME);

	//net.visualize_hidden_units(1, 50);

	if (!cap.isOpened()) {
		cout << "Failed to initialize camera\n";
		return;
	}

	namedWindow("CameraCapture");
	namedWindow("ProcessedCapture");

	cv::Mat frame;
	while (true) {

		cap >> frame;

		cv::Mat processedFrame = processor.process_image(frame);

		if(processedFrame.rows * processedFrame.cols == INPUT_LAYER_SIZE) {

			mat input = loader.to_arma_mat(processedFrame);

			int label = net.predict(input);

			if(label == 0)
				putText(frame, "A", Point(500, 300), FONT_HERSHEY_SCRIPT_SIMPLEX, 2, Scalar::all(0), 3, 8);
			else if(label == 1)
				putText(frame, "E", Point(500, 300), FONT_HERSHEY_SCRIPT_SIMPLEX, 2, Scalar::all(0), 3, 8);
			else if(label == 2)
				putText(frame, "I", Point(500, 300), FONT_HERSHEY_SCRIPT_SIMPLEX, 2, Scalar::all(0), 3, 8);
			else if(label == 3)
				putText(frame, "O", Point(500, 300), FONT_HERSHEY_SCRIPT_SIMPLEX, 2, Scalar::all(0), 3, 8);
			else if(label == 4)
				putText(frame, "U", Point(500, 300), FONT_HERSHEY_SCRIPT_SIMPLEX, 2, Scalar::all(0), 3, 8);
		}

		imshow("CameraCapture", frame);
		imshow("ProcessedCapture", processedFrame);

		int key = waitKey(5);

		if(key == 13) {
			imwrite("captura.jpg", frame);
		}
		if (key == 27)
			break;
	}

	destroyAllWindows();
}
开发者ID:EPineiro,项目名称:NeuralNetworks,代码行数:57,代码来源:Main.cpp

示例2: main

int main( int argc, char** argv )
{
	if(argc == 3)
	{
		ImageProcessor* proc = new ImageProcessor(argv[2]);

		VideoCapture cap;

		if(!cap.open(argv[1]))
		{
			cout << ERROR_STR << "Failed to open " << argv[1] << endl;
			return -1;
		}

		namedWindow("Video output", 1);
		namedWindow("Input", 1);

		namedWindow("Settings", 1);
		createTrackbar("hi", "Settings", &hi, 255);
	    createTrackbar("lo", "Settings", &lo, 255);

	    //createTrackbar("min_hue", "Settings", &minhue, 180);
	    //createTrackbar("max_hue", "Settings", &maxhue, 180);
	    createTrackbar("sat", "Settings", &minsat, 255);
	    createTrackbar("val", "Settings", &minval, 255);

	    namedWindow("Found circles", 1);

		for(;;)
		{
			Mat curFrame;

			cap >> curFrame;

			if (curFrame.empty())
			{
				cout << STATUS_STR << "Frame is empty" << endl;
				break;
			}
			else
			{
				//resize(curFrame, curFrame, Size(), 0.4, 0.4, INTER_AREA);

				Mat fr = proc->process_image(curFrame);

				imshow("Video output", fr);
				imshow("Input", curFrame);

				// cout << "hi = " << hi << " lo = " << lo << endl;

				if(fr.empty())
				{
					cout << STATUS_STR << "Processed frame is empty" << endl;
					break;
				}
			}

			cvWaitKey(5);

			if(waitKey(30) >= 0)
				break;
		}
	}
开发者ID:BorisVasilyev,项目名称:SignRecognition,代码行数:63,代码来源:video_process.cpp


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