Reputation: 23
So I'm getting an error stating "fatal error: opencv2\core\mat.hpp: No such file or directory" when trying to compile a small c++ file from .cpp with MinGW. It happens in one form or another in Sublime Text 3, Atom, and on the command line with "gcc myfile.cpp". I should note that I'm on Windows 10. Here's the code:
#include <iostream>
#include <opencv2\core\mat.hpp>
#include <opencv2\core.hpp>
#include <opencv2\highgui.hpp>
#include <opencv2\core\types.hpp>
#include <opencv2\imgproc.hpp>
int main()
{
std::cout << "Hello World!\n";
cv::Mat img = cv::imread("despair.jpg");
cv::cvtColor(img, img, cv::COLOR_RGBA2GRAY, 1);
cv::imshow("1", img);
cv::waitKey(0);
cv::Mat mask = cv::Mat(img.rows, img.cols, CV_8UC1, cv::Scalar(255));
cv::Rect_ <char> roi = cv::Rect_ <cv::Point>(cv::Point(0, 0), cv::Point(10, 10));
cv::rectangle(mask, roi, cv::Scalar(0), -1);
cv::Scalar colors = cv::mean(img, mask);
}
Things I've done and tried:
Things in my system path right now:
I took this code out of a larger project to test what was going on with it and at this point I'm at my wits end trying to figure out what's wrong. Please send help.
Upvotes: 2
Views: 1199
Reputation: 985
Add -I
option with path to opencv includes and -L
with path to opencv libraries, like this:
gcc -IC:\OpenCV\opencv\build\include -LC:\OpenCV\opencv\build\x64\vc15\lib test_opencv.cpp
Upvotes: 1