我正在尝试执行一个简单的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
提前感谢您的帮助!
答案 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);
}