c++ - cv::Max 中的错误?

标签 c++ opencv opencv-mat

要么我做错了什么,要么 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 Mojave、AppleClang 10 上。OpenCV4.1.0。 我很快就会尝试另一个设置。

最佳答案

基于their documentation中的函数定义

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

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

关于c++ - cv::Max 中的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55695300/

相关文章:

c++ - 使用 GCC 的内联汇编直接调用 C 函数

c++ - 初始化字符串逐元素会导致TLE,但此技术可以正常工作

c++ - LinearHashTable iter 不可取消引用且 iter 不可

c++ - 如何为变化的 `std::map` 计算签名

c++ - CVMat : sizes of input arguments do not match

python - Python Open CV canny正在检测除边缘以外的所有内容

python - 相机标定opencv python鸟瞰视角变换

Python:Urllib2 和 OpenCV

qt - OpenCV Mat到Qt QString

opencv - 将一张 cv::mat 图像叠加在另一张图像上