本文整理汇总了C++中std::vector::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::begin方法的具体用法?C++ vector::begin怎么用?C++ vector::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::vector
的用法示例。
在下文中一共展示了vector::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save
inline void save(
Archive & ar,
const STD::vector<bool, Allocator> &t,
const unsigned int /* file_version */
){
// record number of elements
unsigned int count = t.size();
ar << BOOST_SERIALIZATION_NVP(count);
STD::vector<bool>::const_iterator it = t.begin();
while(count-- > 0){
bool tb = *it++;
ar << boost::serialization::make_nvp("item", tb);
}
}
示例2: set_entities
void BCBase::set_entities(std::vector<int> const & e)const {
this->entities_.assign(e.begin(),e.end());
}
示例3: evaluate_with_Hessian_diagonal
bool CompareMetric::evaluate_with_Hessian_diagonal( PatchData& pd,
size_t handle,
double& value,
std::vector<size_t>& indices,
std::vector<Vector3D>& gradient,
std::vector<SymMatrix3D>& diagonal,
MsqError& err )
{
double m2val;
bool r1, r2;
m2Handles.clear();
m2Grad.clear();
m2Diag.clear();
r1 = metric1->evaluate_with_Hessian_diagonal( pd, handle, value, indices, gradient, diagonal, err ); MSQ_ERRZERO(err);
r2 = metric2->evaluate_with_Hessian_diagonal( pd, handle, m2val, m2Handles, m2Grad, m2Diag, err ); MSQ_ERRZERO(err);
if (r1 != r2 || (r1 && fabs(value - m2val) > epsilon)) {
MSQ_SETERR(err)(MsqError::INVALID_STATE,
"Metrics returned different values for handle %lu in "
"evaluate_with_Hessian_diagonal:\n"
"\t%s %f vs. %s %f\n", (unsigned long)handle,
r1?"true":"false",value,r2?"true":"false",m2val);
}
else {
std::vector<size_t>::const_iterator i, j;
std::vector<Vector3D>::const_iterator r, s;
std::vector<SymMatrix3D>::const_iterator u, v;
int grad_diff = 0, hess_diff = 0;
bool same = (indices.size() == m2Handles.size());
std::sort( m2Handles.begin(), m2Handles.end() );
for (i = indices.begin(); i != indices.end(); ++i) {
j = std::lower_bound( m2Handles.begin(), m2Handles.end(), *i );
if (j == m2Handles.end() || *j != *i) {
same = false;
continue;
}
r = gradient.begin() + (i - indices.begin());
s = m2Grad.begin() + (j - m2Handles.begin());
if (!equal(*r,*s))
++grad_diff;
u = diagonal.begin() + (i - indices.begin());
v = m2Diag.begin() + (j - m2Handles.begin());
if (!equal(*u,*v))
++hess_diff;
}
if (!same) {
MSQ_SETERR(err)(MsqError::INVALID_STATE,
"Metrics returned incompatible lists of vertex indices"
" for handle %lu in evaluate_with_Hessian_diagonal\n.",
(unsigned long)handle );
}
else if (grad_diff) {
MSQ_SETERR(err)(MsqError::INVALID_STATE,
"Metrics returned different gradient vectors for "
" %d of %u vertices for handle %lu in "
"evaluate_with_Hessian_diagonal\n.",
grad_diff, (unsigned)gradient.size(),
(unsigned long)handle );
}
else if (hess_diff) {
MSQ_SETERR(err)(MsqError::INVALID_STATE,
"Metrics returned different Hessian blocks for "
" %d of %u vertices for handle %lu in "
"evaluate_with_Hessian_diagonal\n.",
hess_diff, (unsigned)diagonal.size(),
(unsigned long)handle );
}
}
return r1 && !err;
}
示例4: key
void key(unsigned char key, int /*x*/, int /*y*/)
{
switch ( key )
{
case 'l':
{
loadAnim();
break;
}
case 'c':
{
FILE *file=fopen(animName.c_str(),"w");
fclose(file);
animOri.clear();
animPos.clear();
frameCount = 0;
animTime = 0;
break;
}
case 's':
{
FILE *file=fopen(animName.c_str(),"a");
OSG::Matrix m=cam_trans->getMatrix();
OSG::Quaternion q(m);
OSG::Real32 ax,ay,az,r;
animPos.push_back(OSG::Vec3f(m[3][0],
m[3][1],
m[3][2]));
animOri.push_back(q);
q.getValueAsAxisRad(ax,ay,az,r);
fprintf(file,"%f %f %f %f,%f %f %f\n",ax,ay,az,r,
m[3][0],
m[3][1],
m[3][2]);
fclose(file);
frameCount = 0;
animTime = 0;
break;
}
case 'S':
{
FILE *file=fopen((animName+".wrl").c_str(),"w");
std::vector<OSG::Quaternion>::iterator qit;
fprintf(file,"DEF OriInter OrientationInterpolator {\n\tkey [");
for(size_t i = 0; i < animOri.size(); ++i)
{
fprintf(file, "%f", i / OSG::Real32(animOri.size() - 1) );
if(i < animOri.size() - 1)
fprintf(file,", ");
}
fprintf(file,"]\n\tkeyValue [");
for(qit = animOri.begin(); qit != animOri.end(); ++qit)
{
OSG::Real32 ax,ay,az,r;
(*qit).getValueAsAxisRad(ax,ay,az,r);
fprintf(file, "%f %f %f %f", ax, ay, az, r );
if(qit < animOri.end() - 1)
fprintf(file,", ");
}
fprintf(file,"]\n}\n\n");
std::vector<OSG::Vec3f>::iterator vit;
fprintf(file,"DEF PosInter PositionInterpolator {\n\tkey [");
for(size_t i = 0; i < animPos.size(); ++i)
{
fprintf(file, "%f", i / OSG::Real32(animPos.size() - 1) );
if(i < animPos.size() - 1)
fprintf(file,", ");
}
fprintf(file,"]\n\tkeyValue [");
for(vit = animPos.begin(); vit != animPos.end(); ++vit)
{
OSG::Vec3f v = *vit;
fprintf(file, "%f %f %f, ", v[0], v[1], v[2] );
}
fprintf(file,"]\n}\n\n");
fclose(file);
break;
}
case 'j':
if(sortfirst!=NULL)
{
sortfirst->setCompression("JPEG");
}
break;
case 'r':
if(sortfirst!=NULL)
{
sortfirst->setCompression("RLE");
}
break;
case 'n':
if(sortfirst!=NULL)
{
sortfirst->editCompression().erase();
//.........这里部分代码省略.........
示例5: checkLoot
void LootManager::checkLoot(std::vector<Event_Component> &loot_table, FPoint *pos) {
if (hero == NULL) {
logError("LootManager: checkLoot() failed, no hero.\n");
return;
}
FPoint p;
Event_Component *ec;
ItemStack new_loot;
std::vector<Event_Component*> possible_ids;
int chance = rand() % 100;
// first drop any 'fixed' (0% chance) items
for (unsigned i = loot_table.size(); i > 0; i--) {
ec = &loot_table[i-1];
if (ec->z == 0) {
Point src;
if (pos) {
src = floor(*pos);
}
else {
src.x = ec->x;
src.y = ec->y;
}
p = mapr->collider.get_random_neighbor(src, drop_radius);
if (!mapr->collider.is_valid_position(p.x, p.y, MOVEMENT_NORMAL, false)) {
p = hero->pos;
}
else {
if (src.x == p.x && src.y == p.y)
p = hero->pos;
mapr->collider.block(p.x, p.y, false);
tiles_to_unblock.push_back(floor(p));
}
new_loot.quantity = randBetween(ec->a,ec->b);
// an item id of 0 means we should drop currency instead
if (ec->c == 0 || ec->c == CURRENCY_ID) {
new_loot.item = CURRENCY_ID;
new_loot.quantity = new_loot.quantity * (100 + hero->get(STAT_CURRENCY_FIND)) / 100;
}
else {
new_loot.item = ec->c;
}
addLoot(new_loot, p);
loot_table.erase(loot_table.begin()+i-1);
}
}
// now pick up to 1 random item to drop
int threshold = hero->get(STAT_ITEM_FIND) + 100;
for (unsigned i = 0; i < loot_table.size(); i++) {
ec = &loot_table[i];
int real_chance = ec->z;
if (ec->c != 0 && ec->c != CURRENCY_ID) {
real_chance = (int)((float)ec->z * (hero->get(STAT_ITEM_FIND) + 100) / 100.f);
}
if (real_chance >= chance) {
if (real_chance <= threshold) {
if (real_chance != threshold) {
possible_ids.clear();
}
threshold = real_chance;
}
if (chance <= threshold) {
possible_ids.push_back(ec);
}
}
}
if (!possible_ids.empty()) {
// if there was more than one item with the same chance, randomly pick one of them
int chosen_loot = rand() % possible_ids.size();
ec = possible_ids[chosen_loot];
Point src;
if (pos) {
src = floor(*pos);
}
else {
src.x = ec->x;
src.y = ec->y;
}
p = mapr->collider.get_random_neighbor(src, drop_radius);
if (!mapr->collider.is_valid_position(p.x, p.y, MOVEMENT_NORMAL, false)) {
p = hero->pos;
}
//.........这里部分代码省略.........
示例6: FindPositions
// ------------------------------------------------------------------------------------------------
// Returns an iterator for all positions close to the given position.
void SGSpatialSort::FindPositions( const aiVector3D& pPosition,
uint32_t pSG,
float pRadius,
std::vector<unsigned int>& poResults,
bool exactMatch /*= false*/) const
{
float dist = pPosition * mPlaneNormal;
float minDist = dist - pRadius, maxDist = dist + pRadius;
// clear the array in this strange fashion because a simple clear() would also deallocate
// the array which we want to avoid
poResults.erase( poResults.begin(), poResults.end());
// quick check for positions outside the range
if( mPositions.size() == 0)
return;
if( maxDist < mPositions.front().mDistance)
return;
if( minDist > mPositions.back().mDistance)
return;
// do a binary search for the minimal distance to start the iteration there
unsigned int index = (unsigned int)mPositions.size() / 2;
unsigned int binaryStepSize = (unsigned int)mPositions.size() / 4;
while( binaryStepSize > 1)
{
if( mPositions[index].mDistance < minDist)
index += binaryStepSize;
else
index -= binaryStepSize;
binaryStepSize /= 2;
}
// depending on the direction of the last step we need to single step a bit back or forth
// to find the actual beginning element of the range
while( index > 0 && mPositions[index].mDistance > minDist)
index--;
while( index < (mPositions.size() - 1) && mPositions[index].mDistance < minDist)
index++;
// Mow start iterating from there until the first position lays outside of the distance range.
// Add all positions inside the distance range within the given radius to the result aray
float squareEpsilon = pRadius * pRadius;
std::vector<Entry>::const_iterator it = mPositions.begin() + index;
std::vector<Entry>::const_iterator end = mPositions.end();
if (exactMatch)
{
while( it->mDistance < maxDist)
{
if((it->mPosition - pPosition).SquareLength() < squareEpsilon && it->mSmoothGroups == pSG)
{
poResults.push_back( it->mIndex);
}
++it;
if( end == it )break;
}
}
else
{
// if the given smoothing group is 0, we'll return all surrounding vertices
if (!pSG)
{
while( it->mDistance < maxDist)
{
if((it->mPosition - pPosition).SquareLength() < squareEpsilon)
poResults.push_back( it->mIndex);
++it;
if( end == it)break;
}
}
else while( it->mDistance < maxDist)
{
if((it->mPosition - pPosition).SquareLength() < squareEpsilon &&
(it->mSmoothGroups & pSG || !it->mSmoothGroups))
{
poResults.push_back( it->mIndex);
}
++it;
if( end == it)break;
}
}
}
示例7: removeFromValue
void SudokuGenerator::removeFromValue (std::vector<char>& vector, int pos) const {
vector.erase (vector.begin () + pos);
}
示例8:
void
MaterialData::reinit(const std::vector<MooseSharedPointer<Material> > & mats)
{
for (std::vector<MooseSharedPointer<Material> >::const_iterator it = mats.begin(); it != mats.end(); ++it)
(*it)->computeProperties();
}
示例9:
//recall that n_v is the number of vertices (not the number of tokens in a sentence such as in the previous case)
Graph::Graph(int n_v, std::vector<Edge>& vect) {
no_of_vertices = n_v;
for (std::vector<Edge>::iterator it = vect.begin(); it != vect.end(); it++) {
arr_edge.push_back(*it); //deep copy
}
}
示例10: mainConfigOptionsSetup
int mainConfigOptionsSetup(const std::vector<std::string>& args) {
InitDirs((args.empty() ? "" : *args.begin()));
// read and process command-line arguments, if any
try {
// add entries in options DB that have no other obvious place
GetOptionsDB().AddFlag('h', "help", UserStringNop("OPTIONS_DB_HELP"), false);
GetOptionsDB().AddFlag('g', "generate-config-xml", UserStringNop("OPTIONS_DB_GENERATE_CONFIG_XML"), false);
GetOptionsDB().AddFlag('f', "fullscreen", UserStringNop("OPTIONS_DB_FULLSCREEN"), STORE_FULLSCREEN_FLAG);
GetOptionsDB().Add("reset-fullscreen-size", UserStringNop("OPTIONS_DB_RESET_FSSIZE"), true);
GetOptionsDB().Add<int>("fullscreen-monitor-id", UserStringNop("OPTIONS_DB_FULLSCREEN_MONITOR_ID"), 0, RangedValidator<int>(0, 5));
GetOptionsDB().AddFlag('q', "quickstart", UserStringNop("OPTIONS_DB_QUICKSTART"), false);
GetOptionsDB().AddFlag("auto-advance-first-turn", UserStringNop("OPTIONS_DB_AUTO_FIRST_TURN"), false);
GetOptionsDB().Add<std::string>("load", UserStringNop("OPTIONS_DB_LOAD"), "", Validator<std::string>(), false);
GetOptionsDB().Add("UI.sound.music-enabled", UserStringNop("OPTIONS_DB_MUSIC_ON"), true);
GetOptionsDB().Add("UI.sound.enabled", UserStringNop("OPTIONS_DB_SOUND_ON"), true);
GetOptionsDB().Add<std::string>("version-string", UserStringNop("OPTIONS_DB_VERSION_STRING"),
FreeOrionVersionString(), Validator<std::string>(), true);
GetOptionsDB().AddFlag('r', "render-simple", UserStringNop("OPTIONS_DB_RENDER_SIMPLE"), false);
// Add the keyboard shortcuts
Hotkey::AddOptions(GetOptionsDB());
// read config.xml and set options entries from it, if present
{
XMLDoc doc;
try {
boost::filesystem::ifstream ifs(GetConfigPath());
if (ifs) {
doc.ReadDoc(ifs);
// reject config files from out-of-date version
if (doc.root_node.ContainsChild("version-string") &&
doc.root_node.Child("version-string").Text() == FreeOrionVersionString())
{
GetOptionsDB().SetFromXML(doc);
}
}
} catch (const std::exception&) {
std::cerr << UserString("UNABLE_TO_READ_CONFIG_XML") << std::endl;
}
}
// override previously-saved and default options with command line parameters and flags
GetOptionsDB().SetFromCommandLine(args);
// Handle the case where the resource-dir does not exist anymore
// gracefully by resetting it to the standard path into the
// application bundle. This may happen if a previous installed
// version of FreeOrion was residing in a different directory.
if (!boost::filesystem::exists(GetResourceDir()) ||
!boost::filesystem::exists(GetResourceDir() / "credits.xml") ||
!boost::filesystem::exists(GetResourceDir() / "data" / "art" / "misc" / "missing.png"))
{
Logger().debugStream() << "Resources directory from config.xml missing or does not contain expected files. Resetting to default.";
GetOptionsDB().Set<std::string>("resource-dir", "");
// double-check that resetting actually fixed things...
if (!boost::filesystem::exists(GetResourceDir()) ||
!boost::filesystem::exists(GetResourceDir() / "credits.xml") ||
!boost::filesystem::exists(GetResourceDir() / "data" / "art" / "misc" / "missing.png"))
{
Logger().debugStream() << "Default Resources directory missing or does not contain expected files. Cannot start game.";
std::string path_string;
#if defined(FREEORION_WIN32)
boost::filesystem::path::string_type path_string_native = GetResourceDir().native();
utf8::utf16to8(path_string_native.begin(), path_string_native.end(), std::back_inserter(path_string));
#else
path_string = GetResourceDir().string();
#endif
throw std::runtime_error("Unable to load game resources at default location: " +
path_string + " : Install may be broken.");
}
}
// did the player request generation of config.xml, saving the default (or current) options to disk?
if (GetOptionsDB().Get<bool>("generate-config-xml")) {
try {
boost::filesystem::ofstream ofs(GetConfigPath());
if (ofs) {
GetOptionsDB().GetXML().WriteDoc(ofs);
} else {
std::cerr << UserString("UNABLE_TO_WRITE_CONFIG_XML") << std::endl;
#if defined(FREEORION_WIN32)
boost::filesystem::path::string_type path_string_native = GetConfigPath().native();
std::string path_string;
utf8::utf16to8(path_string_native.begin(), path_string_native.end(), std::back_inserter(path_string));
std::cerr << path_string << std::endl;
#else
std::cerr << GetConfigPath().string() << std::endl;
#endif
}
} catch (const std::exception&) {
std::cerr << UserString("UNABLE_TO_WRITE_CONFIG_XML") << std::endl;
}
//.........这里部分代码省略.........
示例11: cornerPoints
std::vector<Blob> BlobCheck::CheckIfBlobIsLicensePlate(std::vector<Blob> &blobobjects, std::vector< std::vector<int> > blobMap) {
std::vector<Blob> validBlobs;
//check if blob of possible licenseplate
for (std::vector<Blob>::iterator it = blobobjects.begin(); it != blobobjects.end(); ++it) {
double ratio = it->getRatio();
if (ratio >= 2.1 && ratio <= 5.5) {
int edgeCounter = 0;
int lastBlobId = 0;
int smallY = it->getSmallestY();
int smallX = it->getSmallestX();
int bigY = it->getBiggestY();
int bigX = it->getBiggestX();
int y = ((bigY - smallY) / 2) + smallY;
for (int x = smallX; x < bigX; x++){
if (blobMap[y][x] != lastBlobId){
edgeCounter++;
lastBlobId = blobMap[y][x];
}
}
if (edgeCounter >= 5)
validBlobs.insert(validBlobs.end(), *it);
}
}
//std::cout << "validBlobs: " << validBlobs.size() << std::endl;
for (std::vector<Blob>::iterator it = validBlobs.begin(); it != validBlobs.end(); it++) {
int blobId = it->getId();
int h = it->getHeight();
bool labelFound = false;
int cornerTLY = -1;
int cornerTLX = -1;
int cornerTRY = -1;
int cornerTRX = -1;
int cornerBLY = -1;
int cornerBLX = -1;
int cornerBRY = -1;
int cornerBRX = -1;
int minFlatRate = 2;
int lastY = -1;
int flatCnt = 0;
int smallY = it->getSmallestY();
int smallX = it->getSmallestX();
int bigY = it->getBiggestY();
int bigX = it->getBiggestX();
int halfX = smallX + ((bigX - smallX) / 2);
int halfY = smallY + ((bigY - smallY) / 2);
//Top Left
for (int x = halfX; x > smallX; x--) {
for (int y = smallY; y < bigY && labelFound == false; y++) {
//We found the label we are looking for.
if (blobMap[y][x] == blobId) {
labelFound = true;
if (lastY == -1) lastY = y;
if (y == lastY) {
flatCnt++;
if (flatCnt >= minFlatRate && y < halfY) {
cornerTLY = y;
cornerTLX = x;
}
}
else {
flatCnt = 0;
}
lastY = y;
}
}
labelFound = false;
}
flatCnt = 0;
lastY = -1;
//Top right
for (int x = halfX; x < bigX; x++) {
for (int y = smallY; y < bigY && labelFound == false; y++) {
//We found the label we are looking for.
if (blobMap[y][x] == blobId) {
labelFound = true;
if (lastY == -1) lastY = y;
if (y == lastY) {
//.........这里部分代码省略.........
示例12: _CreateGraph
void Permutator::_CreateGraph(BYTE* sectionData, _OffsetType blockOffset, DWORD dwSectionSize, _OffsetType parentOffset,
std::vector<Block>& targets)
{
_DecodeResult res;
unsigned int decodedInstructionsCount = 0;
_DecodeType dt = Decode32Bits;
_OffsetType offset = blockOffset;
_OffsetType offsetEnd;
_DecodedInst decodedInstructions[MAX_INSTRUCTIONS];
unsigned int i;
QWORD tmpOffset = blockOffset;
std::string mnemonic, operand;
bool skipFlag;
while (1)
{
res = distorm_decode(offset, (const unsigned char*)sectionData, dwSectionSize,
dt, decodedInstructions, MAX_INSTRUCTIONS, &decodedInstructionsCount);
if (res == DECRES_INPUTERR)
{
free(sectionData);
return;
}
for (i = 0; i < decodedInstructionsCount; ++i)
{
mnemonic = (reinterpret_cast<char*>(decodedInstructions[i].mnemonic.p));
if (IsJump(mnemonic) ||
mnemonic.compare("RET") == 0 ||
mnemonic.compare("RETN") == 0 ||
mnemonic.substr(0, 2).compare("DB") == 0)
{
break;
}
if (mnemonic.compare("CALL") == 0)
{
std::string functionOperand = reinterpret_cast<char*> (decodedInstructions[i].operands.p);
if (IsRegister(functionOperand) || !IsFunctionOperandValid(functionOperand))
continue;
QWORD functionOffset = std::stoll(functionOperand, nullptr, 0);
graph.AddFunctionOffset(tmpOffset, functionOffset - tmpOffset);
}
tmpOffset += decodedInstructions[i].size;
}
// Main part of graph creation
offsetEnd = decodedInstructions[i].offset;
DWORD blockSize = (DWORD)(offsetEnd + decodedInstructions[i].size - offset);
Node* node = new Node();
// Set 1 to block places in dataBytes
for (DWORD j = 0; j < blockSize; ++j)
{
dataBytes[blockOffset + j] = 1;
}
node->SetOffset((DWORD)offset);
node->SetInstructions(sectionData, blockSize);
// Newly added code
skipFlag = false;
for (std::vector<Block>::iterator it = targets.begin(); it != targets.end(); ++it)
{
if (((*it).offset == node->GetOffset()) && (*it).parentOffset == parentOffset)
{
skipFlag = true;
break;
}
}
if (skipFlag)
return;
Block b;
b.offset = node->GetOffset();
b.parentOffset = parentOffset;
targets.push_back(b);
if (graph.AddNode(node, (DWORD)parentOffset))
{
return;
}
if (mnemonic.compare("RET") == 0 ||
mnemonic.compare("RETN") == 0 ||
mnemonic.substr(0, 2).compare("DB") == 0)
return;
operand = reinterpret_cast<char*>(decodedInstructions[i].operands.p);
operand.resize(decodedInstructions[i].operands.length);
if (IsRegister(operand))
return;
QWORD newOffset = std::stoll(operand, nullptr, 0);
if (!CheckRange(newOffset))
{
std::cerr << "Offset out of CODE section!" << std::endl;
return;
//.........这里部分代码省略.........
示例13: TopK
std::vector<int> TopK2(std::vector<int> &input, int k) {
TopK(input, 0, (int)input.size() - 1, k);
return std::vector<int>(input.begin(), input.begin() + k);
}
示例14: getTracker
void rgb_pcl::getTracker(std::vector<PointCloudPtr> object_clouds, Mat displayImage){
//Assign tracker to the clouds
for(unsigned int count1 = 0; count1 < trackerList.size(); count1++){
cv::Point3d position(0, 0, 0);
double maxScore = 0;
int id_cloud = -1;
cv::Point3d pos_tracker;
int size_tracker;
double hue_tracker;
for(unsigned int count2 = 0; count2 < object_clouds.size(); count2 ++){
int size = object_clouds[count2]->points.size();
cv::Point3d position(0, 0, 0);
double hue = 0;
getCloudFeatures(position, hue, object_clouds[count2]);
double score = trackerList[count1].isRecognized(position, 0, size);
if(score > maxScore){
maxScore = score;
id_cloud = count2;
pos_tracker = position;
size_tracker = size;
hue_tracker = hue;
}
}
if(id_cloud != -1){
trackerList[count1].updateTracker(pos_tracker, hue_tracker, size_tracker, object_clouds[id_cloud]);
object_clouds.erase(object_clouds.begin()+id_cloud);
}
}
// cout<<trackerList.size()<<endl;
//Create new tracker for the remaining clouds
for(auto cloudCluster: object_clouds){
int size = object_clouds[0]->points.size();
cv::Point3d position(0, 0, 0);
double hue = 0;
getCloudFeatures(position, hue, cloudCluster);
track_3d newTracker(position, hue, size);
trackerList.push_back(newTracker);
}
//Delete lost tracker and display tracked clouds
for(unsigned int count = 0; count < trackerList.size(); count ++){
trackerList[count].step();
if(!trackerList[count].isAlive()){
trackerList.erase(trackerList.begin()+count);
count --;
}else if(trackerList[count].isFound() && !trackerList[count].isGone()){
#if DISPLAY
drawTrackers(displayImage, trackerList[count], to_string(count));
#endif
}
}
}
示例15:
void Filters::FilterList::TestElements(std::vector<GContainer::Container *> &test){
std::vector< std::vector<GContainer::Container *> > masterList;
std::vector<GContainer::Container *> originalList = test;
std::vector<GContainer::Container *> newList;
std::vector<FilterGroup *>::iterator gItr = _allFilters.begin();
for(; gItr != _allFilters.end(); gItr++){
std::vector<Filter *>::iterator fItr = (*gItr)->_filters.begin();
for(; fItr != (*gItr)->_filters.end(); fItr++){
GContainer::ContainerIterator * theFilter = (*fItr)->Container()->GetIterator();
if(not theFilter->Begin()){
std::cout << "There was a problem with the Filter." <<std::endl;
exit(-4);
}
std::vector<GContainer::Container *>::iterator itr = test.begin();
for( ; itr != test.end() ; itr++){
bool testVal = false;
GContainer::ContainerIterator * theRecord = (*itr)->GetIterator();
if( not theRecord->Find(theFilter->iterator->first)){
std::cout << "This record has no field " << theFilter->iterator->first << std::endl;
continue;
}
switch((*fItr)->GetType()){
case EQUAL:
testVal = (*(theRecord->iterator->second) == (theFilter->iterator->second));
break;
case CONTAINS:
testVal = false;//(*(theRecord->iterator->second)->Contains(theFilter->iterator->second));
break;
case LESS_THAN:
testVal = (*(theRecord->iterator->second) < (theFilter->iterator->second));
break;
case LESS_THAN_OR_EQUAL:
testVal = (*(theRecord->iterator->second) <= (theFilter->iterator->second));
break;
case GREATER_THAN:
testVal = (*(theRecord->iterator->second) > (theFilter->iterator->second));
break;
case GREATER_THAN_OR_EQUAL:
testVal = (*(theRecord->iterator->second) >= (theFilter->iterator->second));
break;
case NOT_EQUAL:
testVal = (*(theRecord->iterator->second) != (theFilter->iterator->second));
break;
default:
std::cout << "Bad type. Check your filter file." << std::endl;
break;
}
if(testVal){
newList.push_back(*itr);
}
}
test.clear();
test = newList;
newList.clear();
}
masterList.push_back(test);
newList.clear();
test = originalList;
std::cout << " master List has " << masterList.size() << " elements" << std::endl;
}
test.clear();
std::vector< std::vector<GContainer::Container *> >::iterator mItr = masterList.begin();
for(; mItr != masterList.end(); mItr++){
std::vector<GContainer::Container *>::iterator lItr = mItr->begin();
for(; lItr != mItr->end(); lItr++){
test.push_back(*lItr);
}
}
}