cduguet
cduguet

Reputation: 427

bug in cv::Max?

Either I am doing something very wrong, or there is a problem with cv::max. I am calling it in the most obvious way possible:

#include<iostream>
#include<opencv2/opencv.hpp>

int main() {
    cv::Mat t1 = cv::Mat::zeros(cv::Size(3,3), CV_8UC1);
    cv::Mat t2 = cv::Mat::zeros(cv::Size(3,3), CV_8UC1);
    cv::Mat t3;

    cv::max(t1,t2,&t3);
    return 0;
}

and getting:

In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:38:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:500:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:176:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:2627:12: error:
      called object type 'cv::Mat *' is not a function or function pointer
    return __comp(__a, __b) ? __b : __a;
           ^~~~~~

Currently on OSX Mojave, AppleClang 10. OpenCV4.1.0. I will try on another set up soon.

Upvotes: 0

Views: 342

Answers (2)

This is probably a windows re-defintion issue, Ive solved this by adding this, after the windows includes:

//Undefine the max macro
#ifdef max
#undef max
#endif

Upvotes: -1

Jonathon K
Jonathon K

Reputation: 339

Based on the function definition in their documentation

void cv::max(const Mat& src1,
             const Mat& src2,
             Mat& dst 
)

I suspect you're calling the function wrong, by using &t3 you are passing a pointer to a cv::Mat (i.e. cv::Mat*). The definition expects a reference to a cv::Mat. Remove the & cv::max(t1,t2,t3); and it should compile.

Upvotes: 1

Related Questions