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
+15 -4
View File
@@ -125,13 +125,24 @@ void Frame::checkKeyPoints(Feature* ftr)
void Frame::removeKeyPoint(Feature* ftr) void Frame::removeKeyPoint(Feature* ftr)
{ {
std::cerr<<key_pts_.size()<<'\t';
if(key_pts_.size()!=5){
key_pts_.clear();
key_pts_.reserve(5);
return;
}
bool found = false; bool found = false;
std::for_each(key_pts_.begin(), key_pts_.end(), [&](Feature*& i){ for(auto&& key_pt:key_pts_){
if(i == ftr) { std::cerr<<"131\t";
i = NULL; if(key_pt==NULL)continue;
std::cerr<<"131\t";
if(key_pt==ftr){
std::cerr<<"131\t";
key_pt=NULL;
found=true; found=true;
} }
}); }
std::cerr<<"dd\n";
if(found) if(found)
setKeyPoints(); setKeyPoints();
} }
+4 -3
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_){
assert(ftr);
if(ftr->frame!= nullptr)ftr->frame->removeKeyPoint(ftr);
ftr->point=NULL; ftr->point=NULL;
ftr->frame->removeKeyPoint(ftr); }
});
pt->obs_.clear(); pt->obs_.clear();
// Delete mappoint // Delete mappoint