introlab / rtabmap

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

Possible logic error? #337

Closed seanlis closed 6 years ago

seanlis commented 6 years ago

Hi,

https://github.com/introlab/rtabmap/blob/16309e6d1846097cccdf87224330dd8f80bb5de6/corelib/src/util2d.cpp#L206 Should this line be localMinDisparity -= maxCol-leftPyramid[level].cols+1;? If localMinDisparity is added, center.x+localMinDisparity+halfWin.width+1 would get an even larger value, further crossing the Matrix boundary.

matlabbe commented 6 years ago

The logic seems okay.

Example: If localMinDisparity=0, halfWin.width=2 (win size of 5), image size is 640 with largest center.x at 637: https://github.com/introlab/rtabmap/blob/16309e6d1846097cccdf87224330dd8f80bb5de6/corelib/src/util2d.cpp#L203-L207

maxCol=637 + 0 + 2 + 1 = 640
localMinDisparity += 640-640-1 = -1

Because of the following, center.x cannot be larger than 637 in this case: https://github.com/introlab/rtabmap/blob/16309e6d1846097cccdf87224330dd8f80bb5de6/corelib/src/util2d.cpp#L191

While doing some examples, I updated the code to be more robust to bad matches.

seanlis commented 6 years ago

Yeah, you're right. Thanks for the clarification.