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


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

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


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

示例1: detectObject

CvRect HoGProcessor::detectObject(CvSVM *svmModel, IplImage *input, IplImage *result, CvRect rectHead, int normalization){
	int StepWidth = 10;
	int StepHeight = 10;
	
	int nWindow = 3;
	
	int scaleWidth = 2;
	int scaleHeight = 2;

	ImageProcessor ip;

	//loai bo truong hop toc dai
	if(rectHead.height > rectHead.width)
		rectHead.height = rectHead.width;		

	CvRect rectHuman = cvRect(rectHead.x + rectHead.width/2 - rectHead.width*scaleWidth/2, 
		rectHead.y - 6, 
		rectHead.width*scaleWidth, 
		rectHead.height*scaleHeight);

	vector<CvRect> lstRect;
	CvMat* img_feature_vector;
	IplImage **newIntegrals;
	for(int i = 0; i < nWindow; i++)
	{
		for(int j = 0; j < nWindow; j++)
		{
			CvRect rect;
			rect.width = rectHuman.width + StepWidth*i;
			rect.height = rectHuman.height + StepHeight*j;
			rect.x = rectHuman.x - StepWidth*i/2;
			rect.y = rectHuman.y - StepHeight*j/2;
						
			if(rect.x < 0) rect.x = 0;
			if(rect.y < 0) rect.y = 0;
			if(rect.x + rect.width > input->width) rect.width = input->width - rect.x;
			if(rect.y + rect.height > input->height) rect.height = input->height - rect.y;		
			
			IplImage* candidate_img = ip.getSubImageAndResize(input, rect, 48, 48);
			if(candidate_img)
			{
				newIntegrals = calculateIntegralHOG(candidate_img);
				img_feature_vector = calculateHOG_window(newIntegrals,cvRect(0,0,48,48),4);
				
				for (int k = 0; k < 9; k++)
				{
					cvReleaseImage(&newIntegrals[k]);				
				}
				cvReleaseImage(newIntegrals);
				cvReleaseImage(&candidate_img);

				double predict_rs = svmModel->predict(img_feature_vector, true);				
				if(predict_rs >= -1)				
					lstRect.push_back(rect);		
								
				cvReleaseMat(&img_feature_vector);	
			}				
		}
	}	

	if(lstRect.size() > 0)
	{		
		return MergeRect(lstRect);				
	}	
	return cvRect(0,0,-1,-1);	
}
开发者ID:SachinTS,项目名称:khoa-luan-tot-nghiep,代码行数:66,代码来源:HoGProcessor.cpp


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