【发布时间】:2016-09-07 19:00:52
【问题描述】:
我是 OpenCV 的新手,并在 Qt Creator 中使用它。我想显示图像。我的代码是:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <string>
using namespace cv;
using namespace std;
int main( )
{
Mat image=imread("C:/Users/richa/Desktop/IMG-20150324-WA0001.jpg",CV_LOAD_IMAGE_COLOR); // Read the file
if( image.empty() ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow("Image",WINDOW_AUTOSIZE); // Create a window for display.
imshow( "Image", image ); // Show our image inside it.
waitKey(); // Wait for a keystroke in the window
return 0;
}
【问题讨论】:
-
问题可能是您在外部终端中运行程序。只需将您的 QtCreator 配置为在
Check Projects -> Run Settings -> Run in terminal中禁用它。
标签: c++ image qt opencv image-processing