I was trying to run ORB SLAM2 on stereo data in debug in Visual Studio 2017 and it never finds any matches. Weird thing is, if I run it in release, it works quite normally.
ComputeStereoMatches() is never called anywhere else, so this seems to be an error.
As to why this only applies to debug and not release, I assume that since in release the value of mb is a random value of whatever was in memory before initialization, it works most of the time because max disparity is not that important. In debug VS debugger always sets the variable to the same negative value and there it never works because max D is ~0.
I was trying to run ORB SLAM2 on stereo data in debug in Visual Studio 2017 and it never finds any matches. Weird thing is, if I run it in release, it works quite normally.
The problem seems to be that member
Frame.mb
https://github.com/raulmur/ORB_SLAM2/blob/f2e6f51cdc8d067655d90a78c06261378e07e8f3/include/Frame.h#L124-L125is initialized too late in the stereo constructor of frame
https://github.com/raulmur/ORB_SLAM2/blob/f2e6f51cdc8d067655d90a78c06261378e07e8f3/src/Frame.cc#L90-L114
You can see that it is always initialized after calling
ComputeStereoMatches();
, but it's used within that function.https://github.com/raulmur/ORB_SLAM2/blob/f2e6f51cdc8d067655d90a78c06261378e07e8f3/src/Frame.cc#L496-L498
ComputeStereoMatches()
is never called anywhere else, so this seems to be an error.As to why this only applies to debug and not release, I assume that since in release the value of mb is a random value of whatever was in memory before initialization, it works most of the time because max disparity is not that important. In debug VS debugger always sets the variable to the same negative value and there it never works because max D is ~0.
Moving
ComputeStereoMatches()
behind https://github.com/raulmur/ORB_SLAM2/blob/f2e6f51cdc8d067655d90a78c06261378e07e8f3/src/Frame.cc#L114seems to solve the issue.