c++ - OpenCV 错误 : ‘MAT’ is not a member of ‘cv’

标签 c++ opencv image-processing

<分区>

我正在尝试执行一个简单的 OpenCV 程序,但收到以下消息:错误:“MAT”不是“cv”的成员。我按照 docs page 上的说明从源代码安装了 OpenCV .然后我简化了教程 here以尽量减少潜在的问题。这是我的代码:

#include <stdio.h>
#include <opencv2/opencv.hpp>

int main(int argc, char** argv) {
    // Read in image
    cv::MAT im1;
    im1 = cv::imread("opencv-logo.png");
    printf("Done\n");

    return(0);
}

这是我的 CMakeList.txt:

cmake_minimum_required(VERSION 2.8)
project ( pleasework )
find_package( OpenCV REQUIRED)
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( pleasework pleasework.cpp )
target_link_libraries( pleasework ${OpenCV_LIBS} )

令我困惑的是 cv::MAT 抛出错误,但 cv::imread 正常。我查看了 CMakeCache.txt,cmake 似乎发现 OpenCV 正常。

//The directory containing a CMake configuration file for OpenCV.
OpenCV_DIR:PATH=/home/vector/opt/share/OpenCV

预先感谢您的帮助!

最佳答案

您必须将 cv::MAT 更改为 cv::Mat

#include <stdio.h>
#include <opencv2/opencv.hpp>

int main(int argc, char** argv) {
    // Read in image
    cv::Mat im1;
    im1 = cv::imread("opencv-logo.png");
    printf("Done\n");

    return(0);
}

关于c++ - OpenCV 错误 : ‘MAT’ is not a member of ‘cv’ ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43060327/

相关文章:

python - 使用 OpenCV dense SIFT 查找图像之间的匹配

C++ 返回 std::pair<int *,int *>?

c++ - 寻找 : C/C++ Regex library that supports Named Captures

arrays - 为什么像素值保持不变?

c++ - Floyd Steinberg 抖动灰色(pgm ascii)到黑白(pbm ascii)

python - 使用 GDAL 1.6.1 创建 CFloat64 ENVI 文件时出现问题

c++ - 使用输入文件在C++中创建对象

c++ - 英特尔 C++ 编译器错误? (指针别名)

c++ - 异常内核库.dll

java - 如何使用 Opencv 将 PNG 从 Java 类传递到 Android 中的 Native 类