gpt4 book ai didi

c++ - 错误 : Mat is ambiguous when using OpenCV

转载 作者:太空宇宙 更新时间:2023-11-04 15:42:22 24 4
gpt4 key购买 nike

我是 C++ 的新手,我正在尝试使用 OpenCV 提供的一些库。问题是当我把代码放在下面时,它说:

Error: Mat is ambiguous

,我在其他帖子中读到这意味着编译器无法选择要选择的函数,但这正是 OpenCV 教程中调用它的方式。 http://docs.opencv.org/doc/tutorials/introduction/display_image/display_image.html

Mat A;

编辑:我写到现在的代码在.h 文件中:

#pragma once
#include <E:\opencv\build\include\opencv2/highgui/highgui.hpp>
#include <E:\opencv\build\include\opencv2/core/core.hpp>

using namespace cv;
class Face_Detection
{
public:
Face_Detection();

~Face_Detection();

};
int main(){

cv::Mat image;
//A = imread(argv[1], CV_LOAD_IMAGE_COLOR);

return 1;
}

最佳答案

您可以包含其他也定义了 Mat 类型的库/文件。尝试使用,即通过显式添加其命名空间 cv,

cv::Mat A;

而不是为了避免歧义。


编辑:

您包含 OpenCV 头文件的方式让我觉得您没有正确使用 OpenCV。尝试先按照以下帖子正确设置 OpenCV,包括 include/library/...

关于c++ - 错误 : Mat is ambiguous when using OpenCV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21170934/

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