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


C++ Files::saveSignBlobToFile方法代码示例

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


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

示例1: fileName

int
main( int argc, char** argv )
{
	clock_t totalTime;
	totalTime = clock();

	std::map< std::string, std::vector< cv::Rect > > showSigns;

	// --------------------------------------------- read image --------------------------------------------- //
	std::vector< std::string > validExtensions;
	validExtensions.push_back("jpg");
	validExtensions.push_back("png");
	validExtensions.push_back("ppm");
	validExtensions.push_back("jp2");
	Files fh = Files( validExtensions );

	std::vector< std::string > fileNames;
	int nFiles = fh.getFilesInDirectory( benchmarkDir, fileNames );

	std::ofstream File;
	File.open( benchmarkFile );
	int n = 1;

	for( std::vector< std::string >::iterator it = fileNames.begin(); it != fileNames.end(); it++, n++ )
	{
		std::string fileName( (*it) );
		Log::notice( "Processing image: '" + fileName + "' (" + Log::to_string(n) + " of " + Log::to_string(nFiles) + " ).." );

		clock_t t;
		t = clock();

		cv::Mat image = cv::imread( fileName );
		std::vector< std::vector< cv::Point > > data;
		std::vector< cv::Rect > signs;

		RSDS rsd = RSDS( image );

		for( int nm = 0; nm < RSDS::nColorModes; nm ++ )
		{
			// ------------------------------------------- convert to nhs ------------------------------------------- //
			// The second argument of convert_ihls_to_nhs means if it's red or blue. 0 is red, blue is 1.
			// You can put 2 here for others, but then you have to provide the hue max and min, sat min values.
			cv::Mat nhs_image;
			rsd.colorSegmentation( nm, nhs_image );

			// ------------------------------------------- PostProcessing ------------------------------------------- //
			cv::Mat nhs_image_for_post = nhs_image.clone();
			cv::Mat eimg;
			rsd.noiseElimination( nhs_image_for_post, eimg );

			// -------------------------------------- PostProcessing - Convex --------------------------------------- //
			// ------------------------------------ PostProcessing - Get contour ------------------------------------ //
			cv::Mat cimg;
			rsd.convexHullContours( eimg, cimg, data );
		}
		rsd.processCountours( image, data, signs );

		t = clock() - t;
		float calcDuration = ( (float) t ) / CLOCKS_PER_SEC;

		for( std::vector< cv::Rect >::iterator sit = signs.begin(); sit != signs.end(); sit ++ )
		{
//			std::cout << fileName << ";" << (*sit).x << ";" << (*sit).y << ";" << (*sit).x + (*sit).width << ";"
//					<< (*sit).y + (*sit).height << ";" << "-1" << ";" << calcDuration << std::endl;

			fh.saveSignBlobToFile( fileName, (*sit), -1, calcDuration, File );

			std::map< std::string, std::vector< cv::Rect > >::iterator it = showSigns.find(fileName);
			if( it != showSigns.end() )
			{
				it->second.push_back( (*sit) );
			}
			else
			{
				std::vector< cv::Rect > sr;
				sr.push_back( (*sit) );
				showSigns.insert( std::pair< std::string, std::vector< cv::Rect > >( fileName, sr ) );
			}
		}
	}

	File.flush();
	File.close();

	totalTime = clock() - totalTime;
	float calcDuration = ( (float) totalTime ) / CLOCKS_PER_SEC;
	std::cout << "Benchmark processed in " << calcDuration << " seconds." << std::endl;

	std::cout << "The following images have signs in them:" << std::endl;
	for( std::map< std::string, std::vector< cv::Rect > >::iterator it = showSigns.begin(); it != showSigns.end(); it++ )
	{
		cv::Mat result = cv::imread( it->first );

		for( std::vector< cv::Rect >::iterator sit = it->second.begin(); sit != it->second.end(); sit ++ )
		{
			cv::Point2f rect_points[4];
			rect_points[0] = cv::Point2f( (*sit).x, (*sit).y );
			rect_points[1] = cv::Point2f( (*sit).x, (*sit).y + (*sit).width );
			rect_points[2] = cv::Point2f( (*sit).x + (*sit).height, (*sit).y + (*sit).width );
			rect_points[3] = cv::Point2f( (*sit).x + (*sit).height, (*sit).y );
//.........这里部分代码省略.........
开发者ID:jgrocha,项目名称:rdSignDetection,代码行数:101,代码来源:main.cpp


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