remove key point segmentation fault

This commit is contained in:
gfuse
2021-09-02 02:13:37 +02:00
parent 68cd6d9b48
commit f9e61a49ef
2 changed files with 22 additions and 10 deletions
+17 -6
View File
@@ -125,13 +125,24 @@ void Frame::checkKeyPoints(Feature* ftr)
void Frame::removeKeyPoint(Feature* ftr) void Frame::removeKeyPoint(Feature* ftr)
{ {
bool found = false; std::cerr<<key_pts_.size()<<'\t';
std::for_each(key_pts_.begin(), key_pts_.end(), [&](Feature*& i){ if(key_pts_.size()!=5){
if(i == ftr) { key_pts_.clear();
i = NULL; key_pts_.reserve(5);
found = true; return;
} }
}); bool found = false;
for(auto&& key_pt:key_pts_){
std::cerr<<"131\t";
if(key_pt==NULL)continue;
std::cerr<<"131\t";
if(key_pt==ftr){
std::cerr<<"131\t";
key_pt=NULL;
found=true;
}
}
std::cerr<<"dd\n";
if(found) if(found)
setKeyPoints(); setKeyPoints();
} }
+5 -4
View File
@@ -83,10 +83,11 @@ void Map::removePtFrameRef(Frame* frame, Feature* ftr)
void Map::safeDeletePoint(Point* pt) void Map::safeDeletePoint(Point* pt)
{ {
// Delete references to mappoints in all keyframes // Delete references to mappoints in all keyframes
std::for_each(pt->obs_.begin(), pt->obs_.end(), [&](Feature* ftr){ for(auto&& ftr:pt->obs_){
ftr->point=NULL; assert(ftr);
ftr->frame->removeKeyPoint(ftr); if(ftr->frame!= nullptr)ftr->frame->removeKeyPoint(ftr);
}); ftr->point=NULL;
}
pt->obs_.clear(); pt->obs_.clear();
// Delete mappoint // Delete mappoint