opencv cv::Max?

5fjcxozz  于 8个月前  发布在  其他
关注(0)|答案(2)|浏览(91)

要么我做错了什么,要么cv::max有问题。我用最明显的方式来称呼它:

#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;
}

得到:

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;
           ^~~~~~

目前在OSX莫哈韦,AppleClang 10。OpenCV4.1.0。我将尝试另一个设置很快。

4ktjp1zp

4ktjp1zp1#

基于其文档中的函数定义

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

我怀疑你调用的函数是错误的,通过使用&t3,你传递了一个指向cv::Mat的指针(即cv::Mat*)。定义需要一个指向cv::Mat的引用。删除& cv::max(t1,t2,t3);,它应该可以编译。

klh5stk1

klh5stk12#

这可能是一个窗口重新定义的问题,我通过添加这个解决了这个问题,在窗口包括:

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

相关问题