gpt4 book ai didi

c++ - OpenCV Clang mat.hpp 错误 : call to member function 'ptr' is ambiguous

转载 作者:太空狗 更新时间:2023-10-29 23:20:40 34 4
gpt4 key购买 nike

当我通过包含 #include 编译使用 OpenCV 的程序时出现错误,即:

In file included from /usr/local/include/opencv2/highgui/highgui.hpp:46:
In file included from /usr/local/include/opencv2/core/core.hpp:4826:
/usr/local/include/opencv2/core/mat.hpp:2248:42: error: call to member function 'ptr' is ambiguous
{ return (const _Tp*)((SparseMat*)this)->ptr(i0, false, hashval); }
~~~~~~~~~~~~~~~~~~~~^~~
/usr/local/include/opencv2/core/core.hpp:3507:12: note: candidate function
uchar* ptr(int i0, bool createMissing, size_t* hashval=0);
^
/usr/local/include/opencv2/core/core.hpp:3509:12: note: candidate function
uchar* ptr(int i0, int i1, bool createMissing, size_t* hashval=0);
^
/usr/local/include/opencv2/core/core.hpp:3513:12: note: candidate function not viable: no known conversion from 'int' to
'const int *' for 1st argument; take the address of the argument with &
uchar* ptr(const int* idx, bool createMissing, size_t* hashval=0);
^
/usr/local/include/opencv2/core/core.hpp:3511:12: note: candidate function not viable: requires at least 4 arguments, but 3 were
provided
uchar* ptr(int i0, int i1, int i2, bool createMissing, size_t* hashval=0);

我尝试了多个(最近的)版本的 OpenCV,但在我的情况下,它们都不起作用。 OpenCV 正式不支持 Clang,还是我应该报告的错误?我使用 Linux (ubuntu 13.04) 和 clang 3.2-1。

最佳答案

我最近在我的 mac 上遇到了同样的错误。 (2016 年 1 月)

获取错误的过程如下:

  1. 使用 brew 安装 opencv
    酿造安装opencv
    在这种情况下,brew 在 opencv 之前安装 gcc 并使用 gcc NOT clang 编译 opencv。gcc 安装在 /usr/local/Cellar/gcc/5.3.0/bin/

  2. 我编写了我的程序并尝试使用默认选项使用 CMake 进行编译。 cmake 尝试使用 clang 作为编译器:它的位置是 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc

  3. 由于opencv的编译器和程序的编译器不同,所以会产生错误。

因此,我尝试在 cmake 中将编译器设置为 gcc
设置(CMAKE_C_COMPILER/usr/local/Cellar/gcc/5.3.0/bin/gcc-5)
设置(CMAKE_CXX_COMPILER/usr/local/Cellar/gcc/5.3.0/bin/gcc-5)

然后,我通过了那个错误。

关于c++ - OpenCV Clang mat.hpp 错误 : call to member function 'ptr' is ambiguous,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20622867/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com