Ubuntu中用Qt做的GUI一打开图像(imread)就自动关闭,求解!
我在Ubuntu下用Qt做了一个小GUI,功能就是打开一幅图像显示出来,再旋转并显示。但是在“打开”对话框选择了图片文件点击“确定”之后,GUI就自动关闭了。求救!错误提...
我在Ubuntu下用Qt做了一个小GUI,功能就是打开一幅图像显示出来,再旋转并显示。但是在“打开”对话框选择了图片文件点击“确定”之后,GUI就自动关闭了。求救!
错误提示代码如下:
Starting /home/administrator/桌面/C&C++程序_Ubuntu/Qt/build-otherQtGUI-Desktop-Debug/otherQtGUI...
(otherQtGUI:19047): Gtk-WARNING **: gtk_disable_setlocale() must be called before gtk_init()
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/administrator/下载/opencv-2.4.6.1/modules/highgui/src/window.cpp, line 261
terminate called after throwing an instance of 'cv::Exception'
what(): /home/administrator/下载/opencv-2.4.6.1/modules/highgui/src/window.cpp:261: error: (-215) size.width>0 && size.height>0 in function imshow
The program has unexpectedly finished.
/home/administrator/桌面/C&C++程序_Ubuntu/Qt/build-otherQtGUI-Desktop-Debug/otherQtGUI exited with code 0
部分程序代码(用的OpenCV 2.4.6):
void MainWindow::on_pushButton_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image"), ".", tr("Image Files (*.png *.jpg *.bmp)"));
image= cv::imread(fileName.toLatin1().data()); //toAscii改成了toLatin1
cv::namedWindow("Original Image");
cv::imshow("Original Image", image);
} 展开
错误提示代码如下:
Starting /home/administrator/桌面/C&C++程序_Ubuntu/Qt/build-otherQtGUI-Desktop-Debug/otherQtGUI...
(otherQtGUI:19047): Gtk-WARNING **: gtk_disable_setlocale() must be called before gtk_init()
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/administrator/下载/opencv-2.4.6.1/modules/highgui/src/window.cpp, line 261
terminate called after throwing an instance of 'cv::Exception'
what(): /home/administrator/下载/opencv-2.4.6.1/modules/highgui/src/window.cpp:261: error: (-215) size.width>0 && size.height>0 in function imshow
The program has unexpectedly finished.
/home/administrator/桌面/C&C++程序_Ubuntu/Qt/build-otherQtGUI-Desktop-Debug/otherQtGUI exited with code 0
部分程序代码(用的OpenCV 2.4.6):
void MainWindow::on_pushButton_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open Image"), ".", tr("Image Files (*.png *.jpg *.bmp)"));
image= cv::imread(fileName.toLatin1().data()); //toAscii改成了toLatin1
cv::namedWindow("Original Image");
cv::imshow("Original Image", image);
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询