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


C++ Contour::GetLabel方法代码示例

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


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

示例1: GetImageChips

/*******************************************************************
 * Function Name: GetImageChips
 * Return Type 	: int
 * Created On	: Nov 1, 2013
 * Created By 	: hrushi
 * Comments		: Get image chips
 * Arguments	: const Args& args
 *******************************************************************/
mp_Str_vStr AlgoTrain::GetImageChips( const Args& args, const std::map<string, string>& TrkMskMap ) const
{
	static Labels Lbl(args, ALL_LABEL_FILENAME);
	Lbl.Read(args);
	tdef_LabelMap lMap = Lbl.GetLabelMap();

	string TrainFolderPath = args.GetTrainFolderPath();

	if(TrainFolderPath.length() == 0 )
	{
		TrainFolderPath = args.GetSearchFolderPath();
	}

	const string ChipPath = TrainFolderPath + CHIP_FILE_LIST;

	std::map<UINT, string> mpChips = CreateFolders(TrainFolderPath);

	UINT uiPersonChipCnt(0), uiDragCnt(0), uiWornCnt(0);
	vector<string> vPersonImgs, vDragImgs, vWornImgs;

	for (tdef_LabelMap::const_iterator itr = lMap.begin(); itr != lMap.end(); itr++)
	{
		fs::path ImagePath 	= itr->first;
		int MarkLabel		= Lbl.AlreadyPresent(itr->first);
		string CmplImgPath 	  =  Lbl.GetComplateImgFilePath(itr->first);

		//---------- Skip the loop if the image is not present ---------- //
		if(!fs::exists(CmplImgPath))
		{
			continue;
		}

		string sMaskImagePath = "";

		try
		{
			sMaskImagePath = TrkMskMap.at(CmplImgPath);
		}
		catch(const std::out_of_range& oor)
		{
			cerr << "Skip the loop as " << sMaskImagePath << " Not present" << endl;
		}

		ColorImg ProbeImg = ColorImg(CmplImgPath);
		GrayImg MskImg    = GrayImg( sMaskImagePath );

		ContourMap Segments = Detect::GetSegments(ProbeImg, MskImg , false, args);

		//---------- Get type of label. Possible optimization over here. Label files are read again and again ---------- //
		UINT LabelType = Detect::GetType(itr->first, args);

		string FldrPath = mpChips.at(LabelType);

		//Starting from iCntr = 1; Because, iCntr = 0 is Background Contour
		for( int iCntr = 1; iCntr < (int)Segments.AllContourMap.size(); iCntr++ )
		{
			Contour Ctr = Segments.AllContourMap.at(iCntr);
			ColorImg ChipImg = Ctr.GetImgChip(ProbeImg);

			cv::SIFT sift;
			vector<cv::KeyPoint> vkeypoints;
			Mat descriptors;
			Mat WorkImg = ChipImg.GetDataRef().clone();
			sift(WorkImg, Mat(), vkeypoints, descriptors);


			if(0) // Draw keypoints, not used, as it takes a lot of time.
			{
				Mat DispMat;
				cv::drawKeypoints(WorkImg, vkeypoints, DispMat);

				ColorImg DispImg;
				DispImg.SetImage(DispMat);
				DispImg.Display(DISP_DELAY);

				cout << "#Keypoints: " << vkeypoints.size() << endl;

				//---------- Skip the chip if the number of keypoints are less than the number of clusters. ---------- //
				if( vkeypoints.size() < BOW_CLUSERS )
				{
					continue;
				}

			}


			std::stringstream ss;
			if( ( LabelType == DRAG_CARRY_LABEL) && ( Ctr.GetLabel() == (UINT)MarkLabel ))
			{
				FldrPath = mpChips.at(DRAG_CARRY_LABEL);
				ss << FldrPath << "/";
				ss << DRAG << std::setfill('0') << std::setw(4) << uiDragCnt << IMG_EXT_PNG;
//.........这里部分代码省略.........
开发者ID:hnkulkarni,项目名称:DetectCarriedObjs-PerfEval,代码行数:101,代码来源:AlgoTrain.cpp


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