I am new to opencv and I am starting to make a simple code to read and display image in gui ,I am working in qt IDE, first I wirte this block of code
#include <opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
int main()
{
cv::Mat image=cv::imread("image.jpg");
cv::namedWindow("My Image");
cv::imshow("My Image",image);
cv::waitKey(0);
cv::destroyAllWindows();
return 1;
}
But it displays a white window and error in console and then display another window "not responsive" message and then stop working, This is a screen shot http://pbrd.co/1u2A0ow Then I wrote another validity code to check wheater or not the image is been read
int main()
{
Mat image;
cout<<"Size is"<<image.size().height<<","<<image.size().width<<endl;
image=imread("image.jpg");
//Checking first if the image have been read
if(!image.data)
{
cout<<"\n No image has created \n"<<endl;
}
return 1;
}
It displays the message, which means that the image is not read,So The question is How can I successfully read and load image note: The image in the same folder of main.cpp file http://pbrd.co/1u2Bmj1