gaoxiang12 / slambook2

edition 2 of the slambook
MIT License
5.54k stars 2.02k forks source link

ch13 运行时提示 "Segmentation fault (core dumpted)"。 #62

Open LarryDong opened 4 years ago

LarryDong commented 4 years ago

在运行时提示错误"Segmentation fault (core dumpted)" 经过一行行输出,发现问题出现在"visualodometry.cpp"中:bool VisualOdometry::Init()中的`dataset=Dataset::Ptr(new Dataset(Config::Get("dataset_dir")));` 不确定和 issue #18 是否相同。 但下面提供的解决方法能够解决: https://blog.csdn.net/sinat_39720504/article/details/102481421

即,将Config::SetParameterFile函数中
config_->file_ = cv::FileStorage(filename.c_str(), cv::FileStorage::READ);
修改为
static cv::FileStorage file1( filename.c_str(), cv::FileStorage::READ ); config_->file_ = file1;

c++水平不高,也搞不清楚原理。放到这里希望对其他人有所帮助。

ErcBunny commented 1 year ago

That works for me, many thx!

nilonana commented 3 months ago

I encountered the similar question "terminate called after throwing an instance of 'cv::Exception' what(): OpenCV(4.2.0) ../modules/core/src/persistence.cpp:1730: error: (-215:Assertion failed) blockIdx < fs_data_ptrs.size() in function 'getNodePtr'". This solution works as well.