65,186
社区成员




inline std::vector< std::pair<Point, float> > getVotes() const
{
if(buffered.size() > 0)
return buffered;
std::vector< std::pair<Point,float> > ret;
float avg = static_cast<float>(numPos)/(MapSize*MapSize);
for(int x = 0; x < MapSize; x++)
{
for(int y = 0; y < MapSize; y++)
{
float val = voteMap.at<float>(y, x);
if(val > avg)
{
int voteX = static_cast<int>(round((x - MapSize/2.0f) * MapStep));
int voteY = static_cast<int>(round((y - MapSize/2.0f) * MapStep));
ret.push_back( std::make_pair( Point(voteX, voteY), probPos * val / numPos ));
}
}
}
std::sort(ret.begin(), ret.end(), sortVotesDesc);
// ret.resize( std::min(10, (int)ret.size()) );
ret.resize( std::min( 10, (int)(ret.size()) ) );
buffered = ret;
return ret;
}
};