我正在尝试在 Qt Creator 中设置 OpenCV,但遇到了一些问题。我在 Qt Creator .pro 文件中添加了 OpenCV 路径
INCLUDEPATH += /usr/local/include/opencv
LIBS += -L/usr/local/lib \
-lopencv_core \
-lopencv_imgproc \
-lopencv_highgui \
-lopencv_ml \
-lopencv_video \
-lopencv_features2d \
-lopencv_calib3d \
-lopencv_objdetect \
-lopencv_contrib \
-lopencv_legacy \
-lopencv_flann
我想在这段代码中阅读并显示图像
void MainWindow::on_pushButton_clicked()
{
cv::Mat matInput = cv::imread("LP.jpg");
if( matInput.empty())
{
std::cout<<"Can't load image "<<std::endl;
}
cv::namedWindow("Show");
cv::imshow("Show", matInput);
cv::waitKey();
}
当我运行我的项目时,它显示以下消息:
正在启动 /home/vasan/Qt/build-OpenCVWithQt-Desktop-Debug/OpenCVWithQt...
程序意外完成。
/home/vasan/Qt/build-OpenCVWithQt-Desktop-Debug/OpenCVWithQt 退出,代码为 0