I am trying to integrate CUDA into a OpenCV project. However when compiling I get a couple of errors.
c:\opencv2.0\include\opencv\cxoperations.hpp(2469): error: more than one instance of overloaded function “std::abs” matches the argument list:
function “abs(long double)”
function “abs(float)”
function “abs(double)”
function “abs(long)”
function “abs(int)”
argument types are: (ptrdiff_t)
and
c:\opencv2.0\include\opencv\cxoperations.hpp(1137): error: no operator “=” matches these operands
operand types are: const cv::Range = cv::Range
I am a bit confused as I thought that my host code would be passed to the Visual Studio compiler, which on its own in a normal C++ compiles OpenCV just fine.
Any ideas what is happening here, and how to remedy?
I believe line 1137 is a bug in the OpenCV header. You can modify the header to temporarily correct the issue by changing the left side of the statement there to:
The first error doesn’t come up on my machines – but you can probably disambiguate and submit the patch to the OpenCV maintainers. The fact that the cast is ambiguous suggests that it should be fixed, even if it compiles quietly in other contexts.
PS: I have also found it useful to add
#undefSSE2
#undefSSE
#undefMMX
before including OpenCV headers (since NVCC chokes on SSE built-ins). With this handful of hacks, OpenCV interoperates reasonably with CUDA on my system.