Open jliebers opened 5 years ago
Distance is almost zero (as expected).
Floating point computations are not bit-exact in general. So comparing of floating point result via "equal" operator is not a good idea.
I would use condition like this (Google tests syntax):
EXPECT_LE(calculated_shapecontextdistance, 1e-3);
Hello everybody,
I might have found a problem concerning the
cv::ShapeContextDistanceExtractor
-class. I have observed the behavior in a unittest, that for a given image and the extracted contours (viacv::findContours()
), different distances are calculated upon an identity-check of the contour, depending on the platform the software is executed on. In contrast tocv::HausdorffDistanceExtractor
, an identity check does not return a plain-value of 0.0d, but instead a very small difference in the range of ca. 0.0005.The first platform is my notebook, a Lenovo ThinkPad X250 running openSUSE Leap 15.0. The second platform is my university's gitlab-runner, which runs some unittests in its CI/CD-pipeline. The baseimage for the gitlab-runner is opensuse/leap:15.0 and the versions of the installed packages are the same as on my notebook.
I am just wondering, why the same software, compiled and executed on similar but different systems makes
cv::ShapeDistanceExtractor::computeDistance()
return different values, when it is instantiated with acv::ShapeContextDistanceExtractor
, but all the input and preprocessing stays the same and is deterministic?System information (version)
uname -r
:4.12.14-lp150.12.48-default
)g++ -v
:[...] gcc version 7.4.0 (SUSE Linux)
Detailed description
(See above and comments in the unittest.)
Steps to reproduce
Here one can find a unittest which demonstrates the problem. It is written for libboost_test1_66_0. The used image can be downloaded below the unittest. Just in case github performs some kind of compression, I have added the checksum in the unittest.
In the unittest, the same image (see below) is loaded twice to different
cv::Mat
-objects. Then the contours of each Mat is calculated and all the defining points are merged into one big contour-vector. Afterwards,sdeptr->computeDistance()
is invoked to calculate the shapecontext-distance.Unittest
Image to be loaded
Result of executing the unittest on my notebook
Result of executing the unittest on gitlab-runner
It is strange, is it not, that each time the other check fails and vice-versa? Furthermore I am wondering, why an identity-check does not equal zero using the shapecontext-distance (it equals zero for the hausdorff-distance)?
This bugreport is nothing urgent. I just wanted to make the finding public. Thank you in advance for looking into this. :slightly_smiling_face: