Я пытаюсь настроить opencv, некоторый базовый код, чтобы просто начать с него и посмотреть, что я могу сделать.Но каждый раз, когда я пытаюсь скомпилировать приложение, я получаю сообщения об ошибках 'Mutex' is not a member of 'cv'
.Пробовал некоторые другие решения, например. this
Моя среда - VS Code с c_cpp_properties.json
, установленным следующим образом:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}",
"C:\\MinGW\\lib\\gcc\\mingw32\\8.2.0\\include\\c++",
"C:\\MinGW\\lib\\opencv\\build\\include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "C:\\MinGW\\posix\\mingw64\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64",
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
Попробовал несколько переустановок g++
и всего такого minGW
,ничего не работает.
Это мой код main.cpp
:
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <string>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
const string file_name = "sunflower.jpg";
Mat img = imread(file_name);
if( !img.data )
{
cout << "Nie odnalezionu pliku " << file_name;
return -1;
}
const string window_name = "OpenCV_1";
namedWindow(window_name, WINDOW_AUTOSIZE);
imshow(window_name, img);
waitKey(0);
return 0;
}
Вывод на консоль
Executing task: g++ -g -o bin/debug.exe src/main.cpp -IC:\MinGW\lib\opencv\build\include -LC:\MinGW\lib\opencv\build\x64\vc15\bin -llibopencv_highgui242 -llibopencv_features2d242 -llibopencv_flann242 -llibopencv_objdetect242 -llibopencv_video242 -llibopencv_calib3d242 -llibopencv_contrib242 -llibopencv_imgproc242 -llibopencv_core242 -llibopencv_ml242 -llibopencv_legacy242 -llibopencv_nonfree242 -llibopencv_photo242 -llibopencv_stitching242 -llibopencv_videostab242 <
In file included from C:\MinGW\lib\opencv\build\include/opencv2/core.hpp:3290,
from C:\MinGW\lib\opencv\build\include/opencv2/highgui.hpp:46,
from C:\MinGW\lib\opencv\build\include/opencv2/highgui/highgui.hpp:48,
from src/main.cpp:1:
C:\MinGW\lib\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:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:697:9: note: 'std::recursive_mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:60:1:
+#include <mutex>
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:697:9:
typedef std::recursive_mutex Mutex;
^~~
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:698:29: error: 'Mutex' is not a member of 'cv'
typedef std::lock_guard<cv::Mutex> AutoLock;
^~~~~
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:698:29: note: suggested alternative: 'Matx'
typedef std::lock_guard<cv::Mutex> AutoLock;
^~~~~
Matx
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:698:29: error: 'Mutex' is not a member of 'cv'
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:698:29: note: suggested alternative: 'Matx'
typedef std::lock_guard<cv::Mutex> AutoLock;
^~~~~
Matx
C:\MinGW\lib\opencv\build\include/opencv2/core/utility.hpp:698:34: error: template argument 1 is invalid
typedef std::lock_guard<cv::Mutex> AutoLock;
^
The terminal process terminated with exit code: 1
Мне нужна подушка для настройки g ++ таким образом, чтобы компилироватьприложение.Или сделай то, о чем я не знаю.