Skip to content

calib3d: some tests fails using clang on Raspberry Pi 3 #11056

@tomoaki0705

Description

@tomoaki0705
System information (version)
  • OpenCV => master ( c729fbd )
  • Operating System / Platform => Debian (Raspbian) 9.3 / Raspberry Pi 3
  • Compiler => GCC 4.9.2 / Clang 3.7.0
Detailed description
  • The following tests fails from opencv_test_calib3d
[==========] 89 tests from 46 test cases ran. (472539 ms total)
[  PASSED  ] 86 tests.
[  FAILED  ] 3 tests, listed below:
[  FAILED  ] Calib3d_SolveP3P.accuracy
[  FAILED  ] Calib3d_SolvePnPRansac.accuracy
[  FAILED  ] Calib3d_SolvePnP.accuracy

 3 FAILED TESTS
  • On the other hand, when building with GCC, this doesn't happen
[==========] 89 tests from 46 test cases ran. (410682 ms total)
[  PASSED  ] 89 tests.
complex<double> complex2 = 2 * q4 / sqrt_2m;
  • I added some printf and found weird behvior of complex
GCC(expected behavior)   |Clang (weird behavior)
=========================|=========================
q4      :-0.00130684     |q4      :-0.00130684    
2 * q4  :(-0.00261369,0) |2 * q4  :(-0.00261369,0)
sqrt_2m :(0.00617747,0)  |sqrt_2m :(0.00617747,0) 
complex2:(-0.4231,0)     |complex2:(-0.00261369,0)
  • It seems division of complex<double> has something wrong.
  • From this part, the data was different, and concluded as a massive number of failure.
  • Just to make sure, I wrote a small code to check the behaviour.
  • Even for the simplest following code, the result differs between the compiler
#include <iostream>
#include <cmath>
#include <complex>

int main(int argc, char**argv)
{
    std::complex<double> a(-0.00261369, 0);
    std::complex<double> b(0.00617747, 0);

    std::complex<double> c = a / b;
    std::cout << "a" << a << std::endl;
    std::cout << "b" << b << std::endl;
    std::cout << "c" << c << std::endl;

    return 0;
}
=========GCC=========
a(-0.00261369,0)
b(0.00617747,0)
c(-0.4231,0)
=========Clang=======
a(-0.00261369,0)
b(0.00617747,0)
c(-0.00261369,0)
=====GCC Version=====
g++ (Raspbian 4.9.2-10) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

=====Clang Version===
Raspbian clang version 3.7.0-4~bpo8+1 (tags/RELEASE_370/final) (based on LLVM 3.7.0)
Target: arm-unknown-linux-gnueabihf
Thread model: posix
  • I also tried on wandbox but this issue did not reproduce. I didn't use any suspicious clang, I installed clang using apt
  • I added a workaround using ifdef in this code, and avoided the issue.
  • I'll send PR later.
Steps to reproduce
  • run opencv_test_calib3d on Raspbian on Raspberry Pi 3, using clang

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions