Reputation: 49
I followed this guide to install openCV on Ubuntu: https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html
When I try to execute the following program:
#include <opencv2/core/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <math.h>
#include <tiffio.h>
using namespace std;
int main(){
string imageName("images/400nm.tif");
TIFF* tif = TIFFOpen(imageName.c_str(), "r");
Mat image;
return 0;
}
I get the following error executing the command "g++ ssim.cpp -o ssim -ltiff":
ssim.cpp: In function ‘int main()’: ssim.cpp:19:3: error: ‘Mat’ was not declared in this scope Mat image; ^~~ ssim.cpp:19:3: note: suggested alternative: In file included from /usr/local/include/opencv2/core.hpp:59:0, from /usr/local/include/opencv2/core/core.hpp:48, from ssim.cpp:2: /usr/local/include/opencv2/core/mat.hpp:771:18: note: ‘cv::Mat’ class CV_EXPORTS Mat
Does somebody know why I get this and how to solve it? I'm new at using opencv and libtiff so I have no idea about what to do to solve...
Upvotes: 1
Views: 4395
Reputation: 180
It's not really necessary to build openCV from source. Try installing it with
sudo apt-get install libopencv-dev
and try to compile it again.
Also like you said in your comment, make sure you either use namespace cv or cv::Mat.
Upvotes: 1
Reputation: 49
Using the command:
g++ ssim.cpp -o ssim -ltiff -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs
I don't get compiler errors but when I try to execute the command ./ssim I get:
./ssim: error while loading shared libraries: libopencv_core.so.3.4: cannot open shared object file: No such file or directory
Upvotes: 0