OpenCV错误:'MAT'不是'cv'的成员

时间:2017-03-28 03:48:25

标签: c++ opencv image-processing

我正在尝试执行一个简单的OpenCV程序,但收到以下内容:error: ‘MAT’ is not a member of ‘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

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:2)

您必须将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);
}