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


C++ Quad::Set2Points方法代码示例

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


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

示例1: Process

int CVMaxBoxPersistance::Process(CVPipeline * pipe)
{
	if (pipe->quads.Size())
	{
		/// Take quads from pipeline and insert into our array.
		previousQuads.Add(pipe->quads[0]);
		/// If array is long enough, delete oldest one.
		if (previousQuads.Size() > maxFramesToConsider->GetInt())
			previousQuads.RemoveIndex(0, ListOption::RETAIN_ORDER);
		// Take note of the time
		this->lastSeenQuad = lastSeenQuad = Timer::GetCurrentTimeMs();
	}
	else if (this->lastSeenQuad < Timer::GetCurrentTimeMs() - 2000)
	{
		errorString = "No valid quad seen in the past 2 seconds.";
		return -1;
	}
	if (previousQuads.Size() <= 0)
	{
		errorString = "No quads to calculate on";
		return -1;
	}

	// First fetch biggest box.
	Quad biggest = previousQuads[0];
	for (int i = 1; i < previousQuads.Size(); ++i)
	{
		Quad & quad = previousQuads[i];
		if (quad.ManhattanSize() > biggest.ManhattanSize())
			biggest = quad;
	}

	// Then filter out those boxes not within threshold value of biggest one.
	List<Quad> quadsToConsider;
	for (int i = 0; i < previousQuads.Size(); ++i)
	{
		Quad & quad = previousQuads[i];
		if (quad.ManhattanSize() > biggest.ManhattanSize() - threshold->GetInt())
			quadsToConsider.Add(quad);
	}
	/// Calculate an "average" quad based on our known array, skipping 
	/// those which are not within a current threshold of total 
	/// manhattan distance differing from the biggest quad.
	Quad average;
	Vector2i min, max;
	for (int i = 0; i < quadsToConsider.Size(); ++i)
	{
		Quad & quad = quadsToConsider[i];
		min += quad.point1;
		max += quad.point3;
	}
	std::cout<<"\nQuads considered: "<<quadsToConsider.Size();

	min /= quadsToConsider.Size();
	max /= quadsToConsider.Size();
	average.Set2Points(min, max);
	pipe->quads.Clear();
	pipe->quads.Add(average);

	returnType = CVReturnType::QUADS;
	return returnType;
}
开发者ID:erenik,项目名称:engine,代码行数:62,代码来源:CVDataFilters.cpp


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