Here's my code:
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<iostream>
using namespace std;
using namespace cv;
int main()
{
Mat image;
cout << "This image has " << image.rows <<" rows and "<<image.cols<<" columns"<< endl;
image = imread("images.jpg");
if (image.empty()) {
cout << "Image not read properly" << endl;
getchar();
return 0;
}
cout << "The size of the image is " << image.rows << " rows and " << image.cols << " columns." << endl;
cout << "This image has " << image.channels() << " channels." << endl;
namedWindow("Original_Image",CV_WINDOW_AUTOSIZE);
imshow("Original_Image", image);
waitKey(0);
return 0;
}
The window which should display the image is just blank. I'm using Visual Studio 2015, OpenCV 3.2.0.
答案 0 :(得分:-1)
如果图像路径错误,您可能会得到一张空白图片。空白窗口由namedWindow语句给出,该语句只是创建窗口。尝试在imread中提供图像的完整路径(例如,如果您的图像保存在下载下,请将文件路径用作“C:\\ Users \\ name \\ Downloads \\ image.jpg”)。确保在指定文件路径时使用双反斜杠(在基于linux的系统中使用正斜杠,在Windows中使用反斜杠!!)。