Hello community,
I am currently having a problem. I am following the instructions given in this book "OpenCV 2 Computer Vison Application Programming Cookbook" for creating a simple image display program in OpenCV (2.4.10-1) using Qt Creator in Ubuntu 14.04.
The code is as follows:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
int main() {
// read an image
cv::Mat image = cv::imread("/home/wagner/Pictures/bottle_label.jpg");
if ( image.data == NULL ) {
std::cout << "no data loaded" << std::endl;
return -1;
}
else {
// create image window named "My image"
cv::namedWindow("My Image", 1);
// show the image on window
std::cout << "Image loaded" << std::endl;
cv::imshow("My Image", image);
// wait key for 5000 ms
cv::waitKey(5000);
return 0;
}
}
And the contents in the .pro file are
# Standard .pro content for qt console application #
INCLUDEPATH += /usr/local/include/
LIBS += -L/usr/local/lib \
-lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_features2d -lopencv_calib3d
The code compiles, but when I run it the program crashes immediately. The debuger points a SIGSEGV occurring in line 17: cv::namedWindow("My Image", 1)
I don't know what to do. I have other programs that use qt and opencv libraries in the same computer but used cmake to build them and they run fine. Could someone please point out where the problem is?
Thank you in advance