本文整理汇总了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;
}