gaoxiang12 / slambook2

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

ch13线程锁问题/core dumped错误 #132

Closed KerunLi closed 3 years ago

KerunLi commented 3 years ago

请问在feature结构体内, cv::KeyPoint position_ 为什么不需要加锁? 我将特征点检测匹配及前端位姿估计改成了ORB、暴力匹配及solvepnpransac,也就是改了如下函数: DetectFeatures() FindFeaturesInRight() TrackLastFrame() EstimateCurrentPose()

程序运行了多个vo之后出现 I20201211 17:23:45.637341 11167 frontend.cpp:232] Outlier/Inlier in pose estimating: 6/86 I20201211 17:23:45.637359 11167 frontend.cpp:237] Current Pose = 0000.995814 0-0.0753716 000.0517061 0000.165541 000.0750314 0000.997145 00.00849185 0000.892959 0-0.0521985 -0.00457672 0000.998626 000-27.1668 00000000000 00000000000 00000000000 00000000001 I20201211 17:23:45.638559 11167 visual_odometry.cpp:70] VO cost time: 0.0396532 seconds. I20201211 17:23:45.638573 11167 visual_odometry.cpp:45] VO is running I20201211 17:23:45.679141 11167 frontend.cpp:331] Find 109 in the current image. I20201211 17:23:45.679527 11167 frontend.cpp:232] Outlier/Inlier in pose estimating: 2/42 I20201211 17:23:45.679546 11167 frontend.cpp:237] Current Pose = 0000.996134 0-0.0662663 000.0576636 00-0.108772 000.0660445 000000.9978 00.00574519 0000.929336 0-0.0579174 -0.00191462 00000.99832 000-28.3445 00000000000 00000000000 00000000000 00000000001 I20201211 17:23:45.679932 11167 map.cpp:79] remove keyframe 5 I20201211 17:23:45.680708 11167 map.cpp:110] Removed 321 active landmarks I20201211 17:23:45.680716 11167 frontend.cpp:97] Set frame 34 as keyframe 12 I20201211 17:23:45.710675 11167 frontend.cpp:390] Detect 1855 new features I20201211 17:23:45.771710 11167 frontend.cpp:528] Find 315 in the right image. I20201211 17:23:45.807660 11167 frontend.cpp:157] new landmarks: 281 Segmentation fault (core dumped)

core dumped错误,请问有可能是什么原因呢? 目前思路是 线程读写冲突/临时变量过大,程序里只新加了一个智能指针作为feature结构体的数据成员 求大佬指点

gaoxiang12 commented 3 years ago

这个程序目前还没考虑VO多线程方面的事情。 你可以为一些关键变量加锁,锁的颗粒度可以自己控制,不过需要有一些多线程的经验。

KerunLi commented 3 years ago

@gaoxiang12 好的 我试一下,感谢