introlab / rtabmap

RTAB-Map library and standalone application
https://introlab.github.io/rtabmap
Other
2.61k stars 763 forks source link

Add missing filterKeypointsByDepth step #1150

Closed borongyuan closed 8 months ago

borongyuan commented 8 months ago

filterKeypointsByDepth is missing in this if-branch

borongyuan commented 8 months ago

Keypoints with no valid 3D points are mostly because they are too far away to be measured. filterKeypointsByDepth() will remove them. But this doesn't seem to be what we want. Should we consider retaining this part?

matlabbe commented 8 months ago

The features should be already filtered by depth there if _depthAsMask is true and if RGB-D data is provided. For stereo, that could be indeed added. Suggestion:

if(depthMask.empty() && (_feature2D->getMinDepth() > 0.0f || _feature2D->getMaxDepth() > 0.0f))
borongyuan commented 8 months ago
if(depthMask.empty() && (_feature2D->getMinDepth() > 0.0f || _feature2D->getMaxDepth() > 0.0f))

I noticed this doesn't work with ORBOctree. https://github.com/introlab/rtabmap/blob/71bb0cf2262ed73c937312da3b3c7cc8d0ad0f13/corelib/src/opencv/ORBextractor.h#L66

Do other types of features have similar problems?

matlabbe commented 8 months ago
if(depthMask.empty() && (_feature2D->getMinDepth() > 0.0f || _feature2D->getMaxDepth() > 0.0f))

I noticed this doesn't work with ORBOctree.

https://github.com/introlab/rtabmap/blob/71bb0cf2262ed73c937312da3b3c7cc8d0ad0f13/corelib/src/opencv/ORBextractor.h#L66

Do other types of features have similar problems?

I added a new commit to fix OrbOctree ignoring the mask. I think it was the only one ignoring it. I also added my suggestion. It seems to work as expected now.