我试图通过导入opencv运行基本程序以在C ++上显示图像。 它正在导入“ #includes opencv2 / opencv.hpp”,但是在声明MAT类时出现错误。
我是C ++的新手,所以将不胜感激。
代码:
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(){
MAT img = imread("FacialBloodVessels.jpg"); //"FacialBloodVessels.jpg" name of file
namedWindow("image", WINDOW_NORMAL);
imshow("image", img); //display the image imported
waitKey(0);
return 0 ;
}
错误的构建控制台:
09:45:21 **** Incremental Build of configuration Debug for project CppImageProcessing ****
Info: Internal Builder is used for build
g++ "-IC:C:OpenCV\\build\\include" -O0 -g3 -Wall -c -fmessage-length=0 -o Main.o "..\\Main.cpp"
In file included from C:\Users\Ted\OpenCV\build\include/opencv2/core.hpp:3290:0,
from C:\Users\Ted\OpenCV\build\include/opencv2/opencv.hpp:52,
from ..\Main.cpp:12:
C:OpenCV\build\include/opencv2/core/utility.hpp:697:14: error: 'recursive_mutex' in namespace 'std' does not name a type
typedef std::recursive_mutex Mutex;
^~~~~~~~~~~~~~~
C:OpenCV\build\include/opencv2/core/utility.hpp:698:25: error: 'Mutex' is not a member of 'cv'
typedef std::lock_guard<cv::Mutex> AutoLock;
^~
C:OpenCV\build\include/opencv2/core/utility.hpp:698:25: error: 'Mutex' is not a member of 'cv'
C:OpenCV\build\include/opencv2/core/utility.hpp:698:34: error: template argument 1 is invalid
typedef std::lock_guard<cv::Mutex> AutoLock;
^
..\Main.cpp: In function 'int main()':
..\Main.cpp:28:2: error: 'MAT' was not declared in this scope
MAT img = imread("FacialBloodVessels.jpg");
^~~
..\Main.cpp:30:18: error: 'img' was not declared in this scope
imshow("image", img);
^~~
09:45:23 Build Failed. 6 errors, 0 warnings. (took 1s.464ms)